Skip to content

Commit f5d4781

Browse files
committed
Merge branch 'PHP-8.3' into PHP-8.4
2 parents 3c1af3f + 1aeb70f commit f5d4781

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ PHP NEWS
100100
. Fixed bug GH-15657 (Segmentation fault in dasm_x86.h). (nielsdos)
101101
. Added opcache_jit_blacklist() function. (Bob)
102102

103+
- PCRE:
104+
. Fixed GH-16189 (underflow on offset argument). (David Carlier)
105+
103106
- PHPDBG:
104107
. Fixed bug GH-15901 (phpdbg: Assertion failure on i funcs). (cmb)
105108

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)