Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 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
17 changes: 17 additions & 0 deletions ext/calendar/tests/gh16234_2.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
--TEST--
GH-16234 jewishtojd overflow on year argument
--EXTENSIONS--
calendar
--FILE--
<?php
try {
jewishtojd(10, 6, PHP_INT_MIN);
} catch (\ValueError $e) {
echo $e->getMessage(), PHP_EOL;
}
jewishtojd(10, 6, 2147483647);
echo "DONE";
?>
--EXPECTF--
jewishtojd(): Argument #3 ($year) must be between %i and %d
DONE
Loading