@@ -1906,6 +1906,29 @@ zend_op_array *file_cache_compile_file(zend_file_handle *file_handle, int type)
1906
1906
}
1907
1907
#endif
1908
1908
1909
+ int check_persistent_script_access (zend_persistent_script * persistent_script )
1910
+ {
1911
+ char * phar_path , * ptr ;
1912
+ int ret ;
1913
+ if ((ZSTR_LEN (persistent_script -> script .filename )< sizeof ("phar://.phar" )) ||
1914
+ memcmp (ZSTR_VAL (persistent_script -> script .filename ), "phar://" , sizeof ("phar://" )- 1 )) {
1915
+
1916
+ return access (ZSTR_VAL (persistent_script -> script .filename ), R_OK ) != 0 ;
1917
+
1918
+ } else {
1919
+ /* we got a cached file from .phar, so we have to strip prefix and path inside .phar to check access() */
1920
+ phar_path = estrdup (ZSTR_VAL (persistent_script -> script .filename )+ sizeof ("phar://" )- 1 );
1921
+ if ((ptr = strstr (phar_path , ".phar/" )) != NULL )
1922
+ {
1923
+ * (ptr + sizeof (".phar/" )- 2 ) = 0 ; /* strip path inside .phar file */
1924
+ }
1925
+ ret = access (phar_path , R_OK ) != 0 ;
1926
+ efree (phar_path );
1927
+ return ret ;
1928
+ }
1929
+ }
1930
+
1931
+
1909
1932
/* zend_compile() replacement */
1910
1933
zend_op_array * persistent_compile_file (zend_file_handle * file_handle , int type )
1911
1934
{
@@ -2042,7 +2065,7 @@ zend_op_array *persistent_compile_file(zend_file_handle *file_handle, int type)
2042
2065
if (EXPECTED (persistent_script != NULL ) &&
2043
2066
UNEXPECTED (ZCG (accel_directives ).validate_permission ) &&
2044
2067
file_handle -> type == ZEND_HANDLE_FILENAME &&
2045
- UNEXPECTED (access ( ZSTR_VAL ( persistent_script -> script . filename ), R_OK ) != 0 )) {
2068
+ UNEXPECTED (check_persistent_script_access ( persistent_script ) )) {
2046
2069
if (type == ZEND_REQUIRE ) {
2047
2070
zend_message_dispatcher (ZMSG_FAILED_REQUIRE_FOPEN , file_handle -> filename );
2048
2071
zend_bailout ();
0 commit comments