[php-src] master: Merge branch 'PHP-8.4' into PHP-8.5
| From: | Weilin Du | Date: | Wed, 28 Oct 2026 08:13:30 +0000 |
| Subject: | [php-src] master: Merge branch 'PHP-8.4' into PHP-8.5 | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-142875@lists.php.net to get a copy of this message | ||
Author: Weilin Du (LamentXU123)
Date: 2026-10-28T16:08:58+08:00
Commit: https://github.com/php/php-src/commit/32b16a07d66c28d8e09cd2bbaeeda6f1c3f3c307
Raw diff: https://github.com/php/php-src/commit/32b16a07d66c28d8e09cd2bbaeeda6f1c3f3c307.diff
Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
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.c
Diff:
diff --git a/NEWS b/NEWS
index 0698b387f4a8..639997618413 100644
--- a/NEWS
+++ b/NEWS
@@ -80,6 +80,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)
+
- MBString:
. Fixed bug GH-23958 (truncated encoding names resolving to full names). (Kamil Tekiela)
. Fixed out-of-bounds read in php_mb_rfc1867_getword() on a multibyte lead
diff --git a/ext/intl/dateformat/dateformat_parse.c b/ext/intl/dateformat/dateformat_parse.c
index cf80599d9202..3aff36fba4d8 100644
--- a/ext/intl/dateformat/dateformat_parse.c
+++ b/ext/intl/dateformat/dateformat_parse.c
@@ -169,7 +169,7 @@ PHP_FUNCTION(datefmt_parse)
zval *z_parse_pos_tmp = z_parse_pos;
ZVAL_DEREF(z_parse_pos_tmp);
zend_long long_parse_pos = zval_get_long(z_parse_pos_tmp);
- 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;
@@ -212,7 +212,7 @@ 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;
@@ -251,7 +251,7 @@ PHP_FUNCTION(datefmt_localtime)
zval *z_parse_pos_tmp = z_parse_pos;
ZVAL_DEREF(z_parse_pos_tmp);
zend_long long_parse_pos = zval_get_long(z_parse_pos_tmp);
- 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"