Skip to content

Commit 95fa39d

Browse files
committed
Merge branch 'PHP-8.4'
2 parents 3e9f2fa + f5d4781 commit 95fa39d

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

ext/pcre/php_pcre.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1124,6 +1124,11 @@ static void php_do_pcre_match(INTERNAL_FUNCTION_PARAMETERS, bool global) /* {{{
11241124
RETURN_FALSE;
11251125
}
11261126

1127+
if (start_offset == ZEND_LONG_MIN) {
1128+
zend_argument_value_error(5, "must be greater than " ZEND_LONG_FMT, ZEND_LONG_MIN);
1129+
RETURN_THROWS();
1130+
}
1131+
11271132
pce->refcount++;
11281133
php_pcre_match_impl(pce, subject, return_value, subpats,
11291134
global, flags, start_offset);

ext/pcre/tests/gh16189.phpt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
--TEST--
2+
GH-16189 (preg_match/preg_match_all underflow on start_offset argument)
3+
--FILE--
4+
<?php
5+
6+
try {
7+
preg_match( '/<(\w+)[\s\w\-]+ id="S44_i89ew">/', '<br><div id="S44_i89ew">', $matches, 0, PHP_INT_MIN);
8+
} catch (\ValueError $e) {
9+
echo $e->getMessage() . PHP_EOL;
10+
}
11+
try {
12+
preg_match_all( '/<(\w+)[\s\w\-]+ id="S44_i89ew">/', '<br><div id="S44_i89ew">', $matches, 0, PHP_INT_MIN);
13+
} catch (\ValueError $e) {
14+
echo $e->getMessage() . PHP_EOL;
15+
}
16+
?>
17+
--EXPECTF--
18+
preg_match(): Argument #5 ($offset) must be greater than %s
19+
preg_match_all(): Argument #5 ($offset) must be greater than %s

0 commit comments

Comments
 (0)