Fix GH-16189: underflow on preg_match/preg_match_all start_offset.

close GH-16191
This commit is contained in:
David Carlier 2024-10-03 05:15:42 +01:00
parent f14e5cfaaa
commit f453d1ae2a
No known key found for this signature in database
GPG key ID: 8486F847B4B94EF1
3 changed files with 27 additions and 0 deletions

View file

@ -1135,6 +1135,11 @@ static void php_do_pcre_match(INTERNAL_FUNCTION_PARAMETERS, int 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, ZEND_NUM_ARGS() >= 4, flags, start_offset);