Skip to content

Commit c6e34d9

Browse files
committed
Fix bug #77371 (heap buffer overflow in mb regex functions - compile_string_node)
1 parent deb06bb commit c6e34d9

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

ext/mbstring/oniguruma/regcomp.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,7 @@ compile_string_node(Node* node, regex_t* reg)
524524

525525
for (; p < end; ) {
526526
len = enclen(enc, p);
527+
if (p + len > end) len = end - p;
527528
if (len == prev_len) {
528529
slen++;
529530
}

ext/mbstring/tests/bug77371.phpt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
--TEST--
2+
Bug #77371 (heap buffer overflow in mb regex functions - compile_string_node)
3+
--SKIPIF--
4+
<?php extension_loaded('mbstring') or die('skip mbstring not available'); ?>
5+
--FILE--
6+
<?php
7+
var_dump(mb_ereg("()0\xfc00000\xfc00000\xfc00000\xfc",""))
8+
?>
9+
--EXPECT--
10+
bool(false)

0 commit comments

Comments
 (0)