Merge branch 'PHP-8.3' into PHP-8.4

This commit is contained in:
David Carlier 2024-10-11 08:49:00 +01:00
commit f47a45ecff
No known key found for this signature in database
GPG Key ID: 8486F847B4B94EF1
3 changed files with 37 additions and 0 deletions

4
NEWS
View File

@ -19,6 +19,10 @@ PHP NEWS
. Fixed bug GH-16316 (DOMXPath breaks when not initialized properly).
(nielsdos)
- MBstring:
. Fixed bug GH-16361 (mb_substr overflow on start/length arguments).
(David Carlier)
- PHPDBG:
. Fixed bug GH-16174 (Empty string is an invalid expression for ev). (cmb)

View File

@ -2326,6 +2326,16 @@ PHP_FUNCTION(mb_substr)
Z_PARAM_STR_OR_NULL(encoding)
ZEND_PARSE_PARAMETERS_END();
if (from == ZEND_LONG_MIN) {
zend_argument_value_error(2, "must be between " ZEND_LONG_FMT " and " ZEND_LONG_FMT, (ZEND_LONG_MIN + 1), ZEND_LONG_MAX);
RETURN_THROWS();
}
if (!len_is_null && len == ZEND_LONG_MIN) {
zend_argument_value_error(3, "must be between " ZEND_LONG_FMT " and " ZEND_LONG_FMT, (ZEND_LONG_MIN + 1), ZEND_LONG_MAX);
RETURN_THROWS();
}
const mbfl_encoding *enc = php_mb_get_encoding(encoding, 4);
if (!enc) {
RETURN_THROWS();

View File

@ -0,0 +1,23 @@
--TEST--
GH-16320 mb_substr overflow from negative length
--EXTENSIONS--
mbstring
--FILE--
<?php
try {
mb_substr("abcd", PHP_INT_MIN, 4, "UTF-8");
} catch (\ValueError $e) {
echo $e->getMessage() . PHP_EOL;
}
try {
mb_substr("abcd", 0, PHP_INT_MIN, "UTF-8");
} catch (\ValueError $e) {
echo $e->getMessage() . PHP_EOL;
}
var_dump(mb_substr("abcd", PHP_INT_MAX, PHP_INT_MAX, "UTF-8"));
?>
--EXPECTF--
mb_substr(): Argument #2 ($start) must be between %s and %s
mb_substr(): Argument #3 ($length) must be between %s and %s
string(0) ""