@@ -1880,6 +1880,29 @@ zend_op_array *file_cache_compile_file(zend_file_handle *file_handle, int type)
1880
1880
return op_array ;
1881
1881
}
1882
1882
1883
+ int check_persistent_script_access (zend_persistent_script * persistent_script )
1884
+ {
1885
+ char * phar_path , * ptr ;
1886
+ int ret ;
1887
+ if ((ZSTR_LEN (persistent_script -> script .filename )< sizeof ("phar://.phar" )) ||
1888
+ memcmp (ZSTR_VAL (persistent_script -> script .filename ), "phar://" , sizeof ("phar://" )- 1 )) {
1889
+
1890
+ return access (ZSTR_VAL (persistent_script -> script .filename ), R_OK ) != 0 ;
1891
+
1892
+ } else {
1893
+ /* we got a cached file from .phar, so we have to strip prefix and path inside .phar to check access() */
1894
+ phar_path = estrdup (ZSTR_VAL (persistent_script -> script .filename )+ sizeof ("phar://" )- 1 );
1895
+ if ((ptr = strstr (phar_path , ".phar/" )) != NULL )
1896
+ {
1897
+ * (ptr + sizeof (".phar/" )- 2 ) = 0 ; /* strip path inside .phar file */
1898
+ }
1899
+ ret = access (phar_path , R_OK ) != 0 ;
1900
+ efree (phar_path );
1901
+ return ret ;
1902
+ }
1903
+ }
1904
+
1905
+
1883
1906
/* zend_compile() replacement */
1884
1907
zend_op_array * persistent_compile_file (zend_file_handle * file_handle , int type )
1885
1908
{
@@ -2008,7 +2031,7 @@ zend_op_array *persistent_compile_file(zend_file_handle *file_handle, int type)
2008
2031
if (EXPECTED (persistent_script != NULL ) &&
2009
2032
UNEXPECTED (ZCG (accel_directives ).validate_permission ) &&
2010
2033
file_handle -> type == ZEND_HANDLE_FILENAME &&
2011
- UNEXPECTED (access ( ZSTR_VAL ( persistent_script -> script . filename ), R_OK ) != 0 )) {
2034
+ UNEXPECTED (check_persistent_script_access ( persistent_script ) )) {
2012
2035
if (type == ZEND_REQUIRE ) {
2013
2036
zend_message_dispatcher (ZMSG_FAILED_REQUIRE_FOPEN , file_handle -> filename );
2014
2037
zend_bailout ();
0 commit comments