Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,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
Expand Down
6 changes: 3 additions & 3 deletions ext/intl/dateformat/dateformat_parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.", 0);
RETURN_FALSE;
Expand Down Expand Up @@ -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.", 0);
RETURN_FALSE;
Expand Down Expand Up @@ -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.", 0);
RETURN_FALSE;
Expand Down
33 changes: 33 additions & 0 deletions ext/intl/tests/dateformat_parse_offset_out_of_range.phpt
Original file line number Diff line number Diff line change
@@ -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"
Loading