summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2019-07-02 12:28:37 +0200
committerNikita Popov <nikita.ppv@gmail.com>2019-07-02 12:28:37 +0200
commit7174c44557014424d782b369a942e668e7aaeb65 (patch)
treeeba9740e89cefdb44134a5aab11123fe678140a6
parent3e25ddb07bbe5738b37c761ccba72cb4bf77cc16 (diff)
parenta4acff3e21778e8d1f635cf74611b1c13de5ee2a (diff)
downloadphp-git-7174c44557014424d782b369a942e668e7aaeb65.tar.gz
Merge branch 'PHP-7.2' into PHP-7.3
-rw-r--r--ext/opcache/ZendAccelerator.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c
index 4baa779aea..90397bf8d7 100644
--- a/ext/opcache/ZendAccelerator.c
+++ b/ext/opcache/ZendAccelerator.c
@@ -1906,6 +1906,29 @@ zend_op_array *file_cache_compile_file(zend_file_handle *file_handle, int type)
}
#endif
+int check_persistent_script_access(zend_persistent_script *persistent_script)
+{
+ char *phar_path, *ptr;
+ int ret;
+ if ((ZSTR_LEN(persistent_script->script.filename)<sizeof("phar://.phar")) ||
+ memcmp(ZSTR_VAL(persistent_script->script.filename), "phar://", sizeof("phar://")-1)) {
+
+ return access(ZSTR_VAL(persistent_script->script.filename), R_OK) != 0;
+
+ } else {
+ /* we got a cached file from .phar, so we have to strip prefix and path inside .phar to check access() */
+ phar_path = estrdup(ZSTR_VAL(persistent_script->script.filename)+sizeof("phar://")-1);
+ if ((ptr = strstr(phar_path, ".phar/")) != NULL)
+ {
+ *(ptr+sizeof(".phar/")-2) = 0; /* strip path inside .phar file */
+ }
+ ret = access(phar_path, R_OK) != 0;
+ efree(phar_path);
+ return ret;
+ }
+}
+
+
/* zend_compile() replacement */
zend_op_array *persistent_compile_file(zend_file_handle *file_handle, int type)
{
@@ -2042,7 +2065,7 @@ zend_op_array *persistent_compile_file(zend_file_handle *file_handle, int type)
if (EXPECTED(persistent_script != NULL) &&
UNEXPECTED(ZCG(accel_directives).validate_permission) &&
file_handle->type == ZEND_HANDLE_FILENAME &&
- UNEXPECTED(access(ZSTR_VAL(persistent_script->script.filename), R_OK) != 0)) {
+ UNEXPECTED(check_persistent_script_access(persistent_script))) {
if (type == ZEND_REQUIRE) {
zend_message_dispatcher(ZMSG_FAILED_REQUIRE_FOPEN, file_handle->filename);
zend_bailout();