Skip to content

Commit

Permalink
Fix repeated file cache unserialization of zval string
Browse files Browse the repository at this point in the history
The IS_UNSERIALIZED check here does not work if the string is
interned (serialized with file_cache_only=0) but unserialization
happens with file_cache_only=1. In this case the unserializde
string will be in the str area after mem, which is not included
in the script size, and which is also not accessible at this
point without threading through more information. Work around
the problem by checking for the serialized representation instead.
  • Loading branch information
nikic committed Aug 18, 2021
1 parent 8f1a217 commit de7ba3e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion ext/opcache/zend_file_cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -1140,7 +1140,9 @@ static void zend_file_cache_unserialize_zval(zval *zv,
{
switch (Z_TYPE_P(zv)) {
case IS_STRING:
if (!IS_UNSERIALIZED(Z_STR_P(zv))) {
/* We can't use !IS_UNSERIALIZED here, because that does not recognize unserialized
* interned strings in non-shm mode. */
if (IS_SERIALIZED(Z_STR_P(zv)) || IS_SERIALIZED_INTERNED(Z_STR_P(zv))) {
UNSERIALIZE_STR(Z_STR_P(zv));
}
break;
Expand Down

0 comments on commit de7ba3e

Please sign in to comment.