Skip to content

Commit 3d56418

Browse files
committed
Fixed bug #72399 (Use-After-Free in MBString (search_re))
1 parent d1ab974 commit 3d56418

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ PHP NEWS
22
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
33
?? ??? 2016 PHP 7.0.9
44

5+
- Mbstring:
6+
. Fixed bug #72399 (Use-After-Free in MBString (search_re)). (Laruence)
57

68
- Standard:
79
. Fixed bug #72306 (Heap overflow through proc_open and $env parameter).

ext/mbstring/php_mbregex.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,8 +459,12 @@ static php_mb_regex_t *php_mbregex_compile_pattern(const char *pattern, int patl
459459
retval = NULL;
460460
goto out;
461461
}
462+
if (rc == MBREX(search_re)) {
463+
/* reuse the new rc? see bug #72399 */
464+
MBREX(search_re) = NULL;
465+
}
462466
zend_hash_str_update_ptr(&MBREX(ht_rc), (char *)pattern, patlen, retval);
463-
} else if (rc) {
467+
} else {
464468
retval = rc;
465469
}
466470
out:

ext/mbstring/tests/bug72399.phpt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
--TEST--
2+
Bug #72399 (Use-After-Free in MBString (search_re))
3+
--FILE--
4+
<?php
5+
$var5 = mbereg_search_init("","2");
6+
$var6 = mb_eregi_replace("2","","");
7+
$var13 = mbereg_search_pos();
8+
?>
9+
--EXPECTF--
10+
Warning: mbereg_search_pos(): No regex given in %sbug72399.php on line %d

0 commit comments

Comments
 (0)