Skip to content

Commit 5d1636e

Browse files
committed
Leak in failed unserialize() with opcache
With opcache, zend_string_init_interned() will allocate non-interned strings at runtime because shm is locked. Hence, we need to make sure to actually free this string. Fixes OSS-Fuzz #433303828 Closes GH-19211
1 parent 13c781f commit 5d1636e

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ PHP NEWS
2929
- Sockets:
3030
. Fix some potential crashes on incorrect argument value. (nielsdos)
3131

32+
- Standard:
33+
. Fixed OSS Fuzz #417078295 (Leak in failed unserialize() with opcache).
34+
(ilutov)
35+
3236
31 Jul 2025, PHP 8.3.24
3337

3438
- Calendar:
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
--TEST--
2+
OSS-Fuzz #433303828
3+
--FILE--
4+
<?php
5+
6+
unserialize('O:2:"yy": ');
7+
unserialize('O:2:"yy":: ');
8+
9+
?>
10+
--EXPECTF--
11+
Warning: unserialize(): Error at offset 9 of 10 bytes in %s on line %d
12+
13+
Warning: unserialize(): Error at offset 10 of 11 bytes in %s on line %d

ext/standard/var_unserializer.re

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1310,10 +1310,12 @@ object ":" uiv ":" ["] {
13101310
YYCURSOR = *p;
13111311

13121312
if (*(YYCURSOR) != ':') {
1313+
zend_string_release_ex(class_name, 0);
13131314
return 0;
13141315
}
13151316
if (*(YYCURSOR+1) != '{') {
13161317
*p = YYCURSOR+1;
1318+
zend_string_release_ex(class_name, 0);
13171319
return 0;
13181320
}
13191321

0 commit comments

Comments
 (0)