Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions ext/calendar/calendar.c
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,11 @@ PHP_FUNCTION(jewishtojd)
RETURN_THROWS();
}

if (ZEND_LONG_EXCEEDS_INT(year)) {
zend_argument_value_error(3, "must be between %d and %d", INT_MIN, INT_MAX);
RETURN_THROWS();
}

RETURN_LONG(JewishToSdn(year, month, day));
}
/* }}} */
Expand Down
2 changes: 1 addition & 1 deletion ext/calendar/jewish.c
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,7 @@ zend_long JewishToSdn(
int yearLength;
int lengthOfAdarIAndII;

if (year <= 0 || day <= 0 || day > 30) {
if (year <= 0 || year >= 6000 || day <= 0 || day > 30) {
return (0);
}
switch (month) {
Expand Down
11 changes: 11 additions & 0 deletions ext/calendar/tests/gh16234_2.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--TEST--
GH-16234 jewishtojd overflow on year argument
--EXTENSIONS--
calendar
--FILE--
<?php
jewishtojd(10, 6, 2147483647);
echo "DONE";
?>
--EXPECTF--
DONE
21 changes: 21 additions & 0 deletions ext/calendar/tests/gh16234_2_64.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
--TEST--
GH-16234 jewishtojd overflow on year argument
--EXTENSIONS--
calendar
--SKIPIF--
<?php
if (PHP_INT_SIZE == 4) {
die("skip this test is for 64bit platform only");
}
?>
--FILE--
<?php
try {
jewishtojd(10, 6, PHP_INT_MIN);
} catch (\ValueError $e) {
echo $e->getMessage(), PHP_EOL;
}
?>
--EXPECTF--
jewishtojd(): Argument #3 ($year) must be between %i and %d

Loading