Skip to content

Commit 671200a

Browse files
committed
Merge branch 'PHP-8.4'
2 parents e01cde7 + cb04417 commit 671200a

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

ext/calendar/easter.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ static void _cal_easter(INTERNAL_FUNCTION_PARAMETERS, bool gm)
3333
struct tm te;
3434
zend_long year, golden, solar, lunar, pfm, dom, tmp, easter, result;
3535
zend_long method = CAL_EASTER_DEFAULT;
36+
const zend_long max_year = ZEND_LONG_MAX / 1.25;
3637
bool year_is_null = 1;
3738

3839
if (zend_parse_parameters(ZEND_NUM_ARGS(),
@@ -53,6 +54,11 @@ static void _cal_easter(INTERNAL_FUNCTION_PARAMETERS, bool gm)
5354
}
5455
}
5556

57+
if (year <= 0 || year > max_year) {
58+
zend_argument_value_error(1, "must be between 1 and " ZEND_LONG_FMT, max_year);
59+
RETURN_THROWS();
60+
}
61+
5662
#ifdef ZEND_ENABLE_ZVAL_LONG64
5763
/* Compiling for 64bit, allow years between 1970 and 2.000.000.000 */
5864
if (gm && year < 1970) {

ext/calendar/tests/gh16228.phpt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
--TEST--
2+
GH-16228 (easter_days, Overflow on year argument)
3+
--EXTENSIONS--
4+
calendar
5+
--FILE--
6+
<?php
7+
try {
8+
easter_days(PHP_INT_MAX, 0);
9+
} catch (\ValueError $e) {
10+
echo $e->getMessage() . PHP_EOL;
11+
}
12+
try {
13+
easter_days(-1, 0);
14+
} catch (\ValueError $e) {
15+
echo $e->getMessage() . PHP_EOL;
16+
}
17+
try {
18+
easter_date(PHP_INT_MAX, 0);
19+
} catch (\ValueError $e) {
20+
echo $e->getMessage() . PHP_EOL;
21+
}
22+
?>
23+
--EXPECTF--
24+
easter_days(): Argument #1 ($year) must be between 1 and %d
25+
easter_days(): Argument #1 ($year) must be between 1 and %d
26+
easter_date(): Argument #1 ($year) must be between 1 and %d

0 commit comments

Comments
 (0)