1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Merge branch 'PHP-8.4'

This commit is contained in:
David Carlier
2024-10-03 12:49:42 +01:00
2 changed files with 24 additions and 0 deletions

View File

@@ -1124,6 +1124,11 @@ static void php_do_pcre_match(INTERNAL_FUNCTION_PARAMETERS, bool global) /* {{{
RETURN_FALSE;
}
if (start_offset == ZEND_LONG_MIN) {
zend_argument_value_error(5, "must be greater than " ZEND_LONG_FMT, ZEND_LONG_MIN);
RETURN_THROWS();
}
pce->refcount++;
php_pcre_match_impl(pce, subject, return_value, subpats,
global, flags, start_offset);

View File

@@ -0,0 +1,19 @@
--TEST--
GH-16189 (preg_match/preg_match_all underflow on start_offset argument)
--FILE--
<?php
try {
preg_match( '/<(\w+)[\s\w\-]+ id="S44_i89ew">/', '<br><div id="S44_i89ew">', $matches, 0, PHP_INT_MIN);
} catch (\ValueError $e) {
echo $e->getMessage() . PHP_EOL;
}
try {
preg_match_all( '/<(\w+)[\s\w\-]+ id="S44_i89ew">/', '<br><div id="S44_i89ew">', $matches, 0, PHP_INT_MIN);
} catch (\ValueError $e) {
echo $e->getMessage() . PHP_EOL;
}
?>
--EXPECTF--
preg_match(): Argument #5 ($offset) must be greater than %s
preg_match_all(): Argument #5 ($offset) must be greater than %s