[php-src] master: Merge branch 'PHP-8.6'

From: Date: Wed, 28 Oct 2026 08:13:46 +0000
Subject: [php-src] master: Merge branch 'PHP-8.6'
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-142876@lists.php.net to get a copy of this message
Author: Weilin Du (LamentXU123) Date: 2026-10-28T16:11:38+08:00 Commit: https://github.com/php/php-src/commit/c2907d2875b6b98eb10127993d6c8d15bf6ddef4 Raw diff: https://github.com/php/php-src/commit/c2907d2875b6b98eb10127993d6c8d15bf6ddef4.diff Merge branch 'PHP-8.6' * PHP-8.6: Merge branch 'PHP-8.5' into PHP-8.6 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 ext/intl/dateformat/dateformat_parse.cpp Diff: diff --git a/ext/intl/dateformat/dateformat_parse.cpp b/ext/intl/dateformat/dateformat_parse.cpp index 4598a9e93c1f..cf7acd9f05a6 100644 --- a/ext/intl/dateformat/dateformat_parse.cpp +++ b/ext/intl/dateformat/dateformat_parse.cpp @@ -172,7 +172,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; @@ -215,7 +215,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; @@ -257,7 +257,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 (#142876) next »