mirror of
https://github.com/php/php-src.git
synced 2025-08-15 13:38:49 +02:00
Merge branch 'PHP-8.4'
This commit is contained in:
commit
76ade7165e
4 changed files with 42 additions and 9 deletions
|
@ -5080,9 +5080,11 @@ static bool date_period_init_iso8601_string(php_period_obj *dpobj, zend_class_en
|
||||||
|
|
||||||
static bool date_period_init_finish(php_period_obj *dpobj, zend_long options, zend_long recurrences)
|
static bool date_period_init_finish(php_period_obj *dpobj, zend_long options, zend_long recurrences)
|
||||||
{
|
{
|
||||||
if (dpobj->end == NULL && recurrences < 1) {
|
const zend_long max_recurrences = (INT_MAX - 8);
|
||||||
|
|
||||||
|
if (dpobj->end == NULL && (recurrences < 1 || recurrences > max_recurrences)) {
|
||||||
zend_string *func = get_active_function_or_method_name();
|
zend_string *func = get_active_function_or_method_name();
|
||||||
zend_throw_exception_ex(date_ce_date_malformed_period_string_exception, 0, "%s(): Recurrence count must be greater than 0", ZSTR_VAL(func));
|
zend_throw_exception_ex(date_ce_date_malformed_period_string_exception, 0, "%s(): Recurrence count must be greater or equal to 1 and lower than " ZEND_LONG_FMT, ZSTR_VAL(func), max_recurrences + 1);
|
||||||
zend_string_release(func);
|
zend_string_release(func);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -5091,8 +5093,17 @@ static bool date_period_init_finish(php_period_obj *dpobj, zend_long options, ze
|
||||||
dpobj->include_start_date = !(options & PHP_DATE_PERIOD_EXCLUDE_START_DATE);
|
dpobj->include_start_date = !(options & PHP_DATE_PERIOD_EXCLUDE_START_DATE);
|
||||||
dpobj->include_end_date = options & PHP_DATE_PERIOD_INCLUDE_END_DATE;
|
dpobj->include_end_date = options & PHP_DATE_PERIOD_INCLUDE_END_DATE;
|
||||||
|
|
||||||
/* recurrrences */
|
/* recurrences */
|
||||||
dpobj->recurrences = recurrences + dpobj->include_start_date + dpobj->include_end_date;
|
recurrences += dpobj->include_start_date + dpobj->include_end_date;
|
||||||
|
|
||||||
|
if (UNEXPECTED(recurrences > max_recurrences)) {
|
||||||
|
zend_string *func = get_active_function_or_method_name();
|
||||||
|
zend_throw_exception_ex(date_ce_date_malformed_string_exception, 0, "%s(): Recurrence count must be greater or equal to 1 and lower than " ZEND_LONG_FMT " (including options)", ZSTR_VAL(func), max_recurrences + 1);
|
||||||
|
zend_string_release(func);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
dpobj->recurrences = (int)recurrences;
|
||||||
|
|
||||||
dpobj->initialized = 1;
|
dpobj->initialized = 1;
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,6 @@ try {
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
--EXPECT--
|
--EXPECTF--
|
||||||
DatePeriod::__construct(): Recurrence count must be greater than 0
|
DatePeriod::__construct(): Recurrence count must be greater or equal to 1 and lower than %d
|
||||||
DatePeriod::__construct(): Recurrence count must be greater than 0
|
DatePeriod::__construct(): Recurrence count must be greater or equal to 1 and lower than %d
|
||||||
|
|
|
@ -50,5 +50,5 @@ DateMalformedPeriodStringException: DatePeriod::__construct(): ISO interval must
|
||||||
DateMalformedPeriodStringException: DatePeriod::createFromISO8601String(): ISO interval must contain an interval, "R4/2012-07-01T00:00:00Z" given
|
DateMalformedPeriodStringException: DatePeriod::createFromISO8601String(): ISO interval must contain an interval, "R4/2012-07-01T00:00:00Z" given
|
||||||
|
|
||||||
Deprecated: Calling DatePeriod::__construct(string $isostr, int $options = 0) is deprecated, use DatePeriod::createFromISO8601String() instead in %s on line %d
|
Deprecated: Calling DatePeriod::__construct(string $isostr, int $options = 0) is deprecated, use DatePeriod::createFromISO8601String() instead in %s on line %d
|
||||||
DateMalformedPeriodStringException: DatePeriod::__construct(): Recurrence count must be greater than 0
|
DateMalformedPeriodStringException: DatePeriod::__construct(): Recurrence count must be greater or equal to 1 and lower than %d
|
||||||
DateMalformedPeriodStringException: DatePeriod::createFromISO8601String(): Recurrence count must be greater than 0
|
DateMalformedPeriodStringException: DatePeriod::createFromISO8601String(): Recurrence count must be greater or equal to 1 and lower than %d
|
||||||
|
|
22
ext/date/tests/gh14709.phpt
Normal file
22
ext/date/tests/gh14709.phpt
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
--TEST--
|
||||||
|
Bug GH-14709 overflow on reccurences parameter
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
$start = new DateTime('2018-12-31 00:00:00');
|
||||||
|
$interval = new DateInterval('P1M');
|
||||||
|
|
||||||
|
try {
|
||||||
|
new DatePeriod($start, $interval, 2147483640);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
new DatePeriod($start, $interval, 2147483639, DatePeriod::EXCLUDE_START_DATE | DatePeriod::INCLUDE_END_DATE);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
--EXPECTF--
|
||||||
|
DateMalformedPeriodStringException: DatePeriod::__construct(): Recurrence count must be greater or equal to 1 and lower than %d
|
||||||
|
DateMalformedStringException: DatePeriod::__construct(): Recurrence count must be greater or equal to 1 and lower than %d (including options)
|
Loading…
Add table
Add a link
Reference in a new issue