Skip to content

Commit 0f55c20

Browse files
committed
Merge branch 'PHP-8.4'
2 parents 81865ec + e3fe9a9 commit 0f55c20

File tree

4 files changed

+38
-1
lines changed

4 files changed

+38
-1
lines changed

ext/calendar/calendar.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,11 @@ PHP_FUNCTION(jewishtojd)
493493
RETURN_THROWS();
494494
}
495495

496+
if (ZEND_LONG_EXCEEDS_INT(year)) {
497+
zend_argument_value_error(3, "must be between %d and %d", INT_MIN, INT_MAX);
498+
RETURN_THROWS();
499+
}
500+
496501
RETURN_LONG(JewishToSdn(year, month, day));
497502
}
498503
/* }}} */

ext/calendar/jewish.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,7 @@ zend_long JewishToSdn(
710710
int yearLength;
711711
int lengthOfAdarIAndII;
712712

713-
if (year <= 0 || day <= 0 || day > 30) {
713+
if (year <= 0 || year >= 6000 || day <= 0 || day > 30) {
714714
return (0);
715715
}
716716
switch (month) {

ext/calendar/tests/gh16234_2.phpt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--TEST--
2+
GH-16234 jewishtojd overflow on year argument
3+
--EXTENSIONS--
4+
calendar
5+
--FILE--
6+
<?php
7+
jewishtojd(10, 6, 2147483647);
8+
echo "DONE";
9+
?>
10+
--EXPECTF--
11+
DONE

ext/calendar/tests/gh16234_2_64.phpt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
--TEST--
2+
GH-16234 jewishtojd overflow on year argument
3+
--EXTENSIONS--
4+
calendar
5+
--SKIPIF--
6+
<?php
7+
if (PHP_INT_SIZE == 4) {
8+
die("skip this test is for 64bit platform only");
9+
}
10+
?>
11+
--FILE--
12+
<?php
13+
try {
14+
jewishtojd(10, 6, PHP_INT_MIN);
15+
} catch (\ValueError $e) {
16+
echo $e->getMessage(), PHP_EOL;
17+
}
18+
?>
19+
--EXPECTF--
20+
jewishtojd(): Argument #3 ($year) must be between %i and %d
21+

0 commit comments

Comments
 (0)