diff options
author | Xinchen Hui <laruence@gmail.com> | 2018-08-16 13:56:37 +0800 |
---|---|---|
committer | Xinchen Hui <laruence@gmail.com> | 2018-08-16 13:56:37 +0800 |
commit | a879f4dd225d2a263e8a04e078b764757355ccec (patch) | |
tree | fc88b92e6a2cae97ff59be266e86cd28bb0f4951 | |
parent | 56abfd2798bed7d33885900f07e5f0442b079616 (diff) | |
parent | 8c92442b4988a07f683439401da8372af0eba2b3 (diff) | |
download | php-git-a879f4dd225d2a263e8a04e078b764757355ccec.tar.gz |
Merge branch 'PHP-7.1' into PHP-7.2
* PHP-7.1:
Fixed bug #76747 (Opcache treats path containing "test.pharma.tld" as a phar file)
-rw-r--r-- | ext/opcache/ZendAccelerator.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c index 594d8d1090..4ab3983940 100644 --- a/ext/opcache/ZendAccelerator.c +++ b/ext/opcache/ZendAccelerator.c @@ -1253,6 +1253,13 @@ static void zend_accel_add_key(char *key, unsigned int key_length, zend_accel_ha } } +static zend_always_inline zend_bool is_phar_file(zend_string *filename) +{ + return filename && ZSTR_LEN(filename) >= sizeof(".phar") && + !memcmp(ZSTR_VAL(filename) + ZSTR_LEN(filename) - (sizeof(".phar")-1), ".phar", sizeof(".phar")-1) && + !strstr(ZSTR_VAL(filename), "://"); +} + #ifdef HAVE_OPCACHE_FILE_CACHE static zend_persistent_script *store_script_in_file_cache(zend_persistent_script *new_persistent_script) { @@ -1277,10 +1284,7 @@ static zend_persistent_script *store_script_in_file_cache(zend_persistent_script zend_shared_alloc_destroy_xlat_table(); - new_persistent_script->is_phar = - new_persistent_script->script.filename && - strstr(ZSTR_VAL(new_persistent_script->script.filename), ".phar") && - !strstr(ZSTR_VAL(new_persistent_script->script.filename), "://"); + new_persistent_script->is_phar = is_phar_file(new_persistent_script->script.filename); /* Consistency check */ if ((char*)new_persistent_script->mem + new_persistent_script->size != (char*)ZCG(mem)) { @@ -1402,10 +1406,7 @@ static zend_persistent_script *cache_script_in_shared_memory(zend_persistent_scr zend_shared_alloc_destroy_xlat_table(); - new_persistent_script->is_phar = - new_persistent_script->script.filename && - strstr(ZSTR_VAL(new_persistent_script->script.filename), ".phar") && - !strstr(ZSTR_VAL(new_persistent_script->script.filename), "://"); + new_persistent_script->is_phar = is_phar_file(new_persistent_script->script.filename); /* Consistency check */ if ((char*)new_persistent_script->mem + new_persistent_script->size != (char*)ZCG(mem)) { |