1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Merge branch 'PHP-8.2' into PHP-8.3

This commit is contained in:
David Carlier
2024-10-05 13:09:43 +01:00
3 changed files with 34 additions and 0 deletions

2
NEWS
View File

@@ -4,6 +4,8 @@ PHP NEWS
- Calendar:
. Fixed GH-16240: jdtounix overflow on argument value. (David Carlier)
. Fixed GH-16241: easter_days/easter_date overflow on year argument.
(David Carlier)
- CLI:
. Fixed bug GH-16137: duplicate http headers when set several times by

View File

@@ -33,6 +33,7 @@ static void _cal_easter(INTERNAL_FUNCTION_PARAMETERS, bool gm)
struct tm te;
zend_long year, golden, solar, lunar, pfm, dom, tmp, easter, result;
zend_long method = CAL_EASTER_DEFAULT;
const zend_long max_year = ZEND_LONG_MAX / 1.25;
bool year_is_null = 1;
if (zend_parse_parameters(ZEND_NUM_ARGS(),
@@ -53,6 +54,11 @@ static void _cal_easter(INTERNAL_FUNCTION_PARAMETERS, bool gm)
}
}
if (year <= 0 || year > max_year) {
zend_argument_value_error(1, "must be between 1 and " ZEND_LONG_FMT, max_year);
RETURN_THROWS();
}
#ifdef ZEND_ENABLE_ZVAL_LONG64
/* Compiling for 64bit, allow years between 1970 and 2.000.000.000 */
if (gm && year < 1970) {

View File

@@ -0,0 +1,26 @@
--TEST--
GH-16228 (easter_days, Overflow on year argument)
--EXTENSIONS--
calendar
--FILE--
<?php
try {
easter_days(PHP_INT_MAX, 0);
} catch (\ValueError $e) {
echo $e->getMessage() . PHP_EOL;
}
try {
easter_days(-1, 0);
} catch (\ValueError $e) {
echo $e->getMessage() . PHP_EOL;
}
try {
easter_date(PHP_INT_MAX, 0);
} catch (\ValueError $e) {
echo $e->getMessage() . PHP_EOL;
}
?>
--EXPECTF--
easter_days(): Argument #1 ($year) must be between 1 and %d
easter_days(): Argument #1 ($year) must be between 1 and %d
easter_date(): Argument #1 ($year) must be between 1 and %d