From: Christoph M. Becker Date: Thu, 20 Jun 2019 15:53:10 +0000 (+0200) Subject: Fix #78189: file cache strips last character of uname hash X-Git-Tag: php-7.2.21RC1~36 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fcd6f2de60e1fc593fa301f3af42b871624946d9;p=php Fix #78189: file cache strips last character of uname hash We must not forget to increase `len` by one to cater to the directory separator. --- diff --git a/NEWS b/NEWS index 104a71dbfb..ae34c8f442 100644 --- a/NEWS +++ b/NEWS @@ -9,6 +9,9 @@ PHP NEWS - Date: . Fixed #69044 (discrepency between time and microtime). (krakjoe) +- OPcache: + . Fixed #78189 (file cache strips last character of uname hash). (cmb) + 27 Jun 2019, PHP 7.2.20 - Core: diff --git a/ext/opcache/tests/bug78189.phpt b/ext/opcache/tests/bug78189.phpt new file mode 100644 index 0000000000..49891c8d63 --- /dev/null +++ b/ext/opcache/tests/bug78189.phpt @@ -0,0 +1,22 @@ +--TEST-- +Bug #78189 (file cache strips last character of uname hash) +--SKIPIF-- + +--INI-- +opcache.enable_cli=1 +opcache.optimization_level=-1 +opcache.file_cache={TMP} +opcache.file_cache_only=1 +--FILE-- + +--EXPECT-- +int(1) diff --git a/ext/opcache/zend_file_cache.c b/ext/opcache/zend_file_cache.c index 20f21d6a83..39de839e47 100644 --- a/ext/opcache/zend_file_cache.c +++ b/ext/opcache/zend_file_cache.c @@ -775,7 +775,7 @@ static char *zend_file_cache_get_bin_file_path(zend_string *script_path) memcpy(filename, ZCG(accel_directives).file_cache, len); filename[len] = '\\'; memcpy(filename + 1 + len, md5uname, 32); - len += 32; + len += 1 + 32; filename[len] = '\\'; memcpy(filename + len + 1, ZCG(system_id), 32);