Skip to content

Commit be46545

Browse files
authored
Fix pcre out-of-bounds when using closing symbols as opening delimiter (#12946)
Apparently we support using closing symbols )]}> as opening and closing delimiters. Fixes oss-fuzz #65021
1 parent 0917a36 commit be46545

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

ext/pcre/php_pcre.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,7 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache_ex(zend_string *regex, bo
655655
}
656656

657657
start_delimiter = delimiter;
658-
if ((pp = strchr("([{< )]}>", delimiter)))
658+
if ((pp = strchr("([{< )]}> )]}>", delimiter)))
659659
delimiter = pp[5];
660660
end_delimiter = delimiter;
661661

ext/pcre/tests/oss-fuzz-65021.phpt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--TEST--
2+
oss-fuzz #65021
3+
--FILE--
4+
<?php
5+
var_dump(preg_match(">",""));
6+
var_dump(preg_match(">foo>i","FOO"));
7+
?>
8+
--EXPECTF--
9+
Warning: preg_match(): No ending delimiter '>' found in %s on line %d
10+
bool(false)
11+
int(1)

0 commit comments

Comments
 (0)