Skip to content

Commit 4a08885

Browse files
committed
Merge branch 'PHP-7.3' into PHP-7.4
2 parents a7881df + 7174c44 commit 4a08885

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

ext/opcache/ZendAccelerator.c

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1880,6 +1880,29 @@ zend_op_array *file_cache_compile_file(zend_file_handle *file_handle, int type)
18801880
return op_array;
18811881
}
18821882

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+
18831906
/* zend_compile() replacement */
18841907
zend_op_array *persistent_compile_file(zend_file_handle *file_handle, int type)
18851908
{
@@ -2008,7 +2031,7 @@ zend_op_array *persistent_compile_file(zend_file_handle *file_handle, int type)
20082031
if (EXPECTED(persistent_script != NULL) &&
20092032
UNEXPECTED(ZCG(accel_directives).validate_permission) &&
20102033
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))) {
20122035
if (type == ZEND_REQUIRE) {
20132036
zend_message_dispatcher(ZMSG_FAILED_REQUIRE_FOPEN, file_handle->filename);
20142037
zend_bailout();

0 commit comments

Comments
 (0)