[php-src] PHP-8.6: Merge branch 'PHP-8.5' into PHP-8.6

From: Date: Wed, 28 Oct 2026 08:13:33 +0000
Subject: [php-src] PHP-8.6: Merge branch 'PHP-8.5' into PHP-8.6
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-142874@lists.php.net to get a copy of this message
Author: Weilin Du (LamentXU123) Date: 2026-10-28T16:10:58+08:00 Commit: https://github.com/php/php-src/commit/e427f87653f72e1aca95f8d4db7aac7e948c1ae7 Raw diff: https://github.com/php/php-src/commit/e427f87653f72e1aca95f8d4db7aac7e948c1ae7.diff Merge branch 'PHP-8.5' into PHP-8.6 * PHP-8.5: Merge branch 'PHP-8.4' into PHP-8.5 Fix IntlDateFormatter parse functions truncating an $offset below INT_MIN (#24781) Changed paths: A ext/intl/tests/dateformat_parse_offset_out_of_range.phpt M NEWS M ext/intl/dateformat/dateformat_parse.cpp Diff: diff --git a/NEWS b/NEWS index 42aabc577320..66e466e98e5d 100644 --- a/NEWS +++ b/NEWS @@ -45,6 +45,10 @@ PHP NEWS - Hash: . Fix GOST and Snefru digests of 512 MiB or more. (Martin Mirchev) +- Intl: + . Fixed IntlDateFormatter parse functions truncating an $offset below + INT_MIN. (Marc Bennewitz) + - Opcache: . Fixed tracing JIT returning a wrapped integer instead of a float on integer overflow after an integer was compared with a float or diff --git a/ext/intl/dateformat/dateformat_parse.cpp b/ext/intl/dateformat/dateformat_parse.cpp index 8a554ae404de..d71c360026ae 100644 --- a/ext/intl/dateformat/dateformat_parse.cpp +++ b/ext/intl/dateformat/dateformat_parse.cpp @@ -174,7 +174,7 @@ U_CFUNC PHP_FUNCTION(datefmt_parse) zend_argument_type_error(hasThis() ? 2 : 3, "must be of type int, %s given", zend_zval_value_name(z_parse_pos)); RETURN_THROWS(); } - if (ZEND_LONG_INT_OVFL(long_parse_pos)) { + if (ZEND_LONG_EXCEEDS_INT(long_parse_pos)) { intl_error_set_code(NULL, U_ILLEGAL_ARGUMENT_ERROR); intl_error_set_custom_msg(NULL, "String index is out of valid range."); RETURN_FALSE; @@ -217,7 +217,7 @@ U_CFUNC PHP_METHOD(IntlDateFormatter, parseToCalendar) zend_argument_type_error(2, "must be of type int, %s given", zend_zval_value_name(z_parse_pos)); RETURN_THROWS(); } - if (ZEND_LONG_INT_OVFL(long_parse_pos)) { + if (ZEND_LONG_EXCEEDS_INT(long_parse_pos)) { intl_error_set_code(NULL, U_ILLEGAL_ARGUMENT_ERROR); intl_error_set_custom_msg(NULL, "String index is out of valid range."); RETURN_FALSE; @@ -259,7 +259,7 @@ U_CFUNC PHP_FUNCTION(datefmt_localtime) zend_argument_type_error(hasThis() ? 2 : 3, "must be of type int, %s given", zend_zval_value_name(z_parse_pos)); RETURN_THROWS(); } - if (ZEND_LONG_INT_OVFL(long_parse_pos)) { + if (ZEND_LONG_EXCEEDS_INT(long_parse_pos)) { intl_error_set_code(NULL, U_ILLEGAL_ARGUMENT_ERROR); intl_error_set_custom_msg(NULL, "String index is out of valid range."); RETURN_FALSE; diff --git a/ext/intl/tests/dateformat_parse_offset_out_of_range.phpt b/ext/intl/tests/dateformat_parse_offset_out_of_range.phpt new file mode 100644 index 000000000000..3347665eb3bf --- /dev/null +++ b/ext/intl/tests/dateformat_parse_offset_out_of_range.phpt @@ -0,0 +1,33 @@ +--TEST-- +IntlDateFormatter parse functions reject an offset below INT_MIN +--EXTENSIONS-- +intl +--SKIPIF-- +<?php +if (PHP_INT_SIZE <= 4) die('skip requires a 64-bit zend_long'); +?> +--FILE-- +<?php +/* -4294967295 used to be truncated to an int32_t of 1, so parsing started + * at offset 1 instead of failing. */ +$fmt = new IntlDateFormatter('en_US', IntlDateFormatter::FULL, IntlDateFormatter::FULL, 'UTC', null, 'yyyy'); + +$offset = -4294967295; +var_dump(datefmt_parse($fmt, '12026', $offset), $offset, intl_get_error_message()); + +$offset = -4294967295; +var_dump($fmt->parseToCalendar('12026', $offset), $offset, intl_get_error_message()); + +$offset = -4294967295; +var_dump(datefmt_localtime($fmt, '12026', $offset), $offset, intl_get_error_message()); +?> +--EXPECTF-- +bool(false) +int(-4294967295) +string(%d) "%SString index is out of valid range.: U_ILLEGAL_ARGUMENT_ERROR" +bool(false) +int(-4294967295) +string(%d) "%SString index is out of valid range.: U_ILLEGAL_ARGUMENT_ERROR" +bool(false) +int(-4294967295) +string(%d) "%SString index is out of valid range.: U_ILLEGAL_ARGUMENT_ERROR"

« previous php.cvs (#142874) next »