Skip to content

Commit b2cea91

Browse files
committed
Fix GH-16228 overflow on easter_days/easter_date year argument.
1 parent 3d80d98 commit b2cea91

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

ext/calendar/easter.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ static void _cal_easter(INTERNAL_FUNCTION_PARAMETERS, bool gm)
4848
}
4949
}
5050

51+
if (year < 0 || year > (ZEND_LONG_MAX - 1)) {
52+
zend_argument_value_error(1, "must be between 0 and " ZEND_LONG_FMT, (ZEND_LONG_MAX - 1));
53+
RETURN_THROWS();
54+
}
55+
5156
if (gm && (year<1970 || year>2037)) { /* out of range for timestamps */
5257
zend_argument_value_error(1, "must be between 1970 and 2037 (inclusive)");
5358
RETURN_THROWS();

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 0 and %d
25+
easter_days(): Argument #1 ($year) must be between 0 and %d
26+
easter_date(): Argument #1 ($year) must be between 0 and %d

0 commit comments

Comments
 (0)