Skip to content

Commit 237bb37

Browse files
committed
Fix GH-16235 jdtogregorian overflow
1 parent 3d80d98 commit 237bb37

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

ext/calendar/gregor.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,10 @@ void SdnToGregorian(
153153
}
154154
temp = (sdn + GREGOR_SDN_OFFSET) * 4 - 1;
155155

156+
if (temp < 0 || (temp / DAYS_PER_400_YEARS) > INT_MAX) {
157+
goto fail;
158+
}
159+
156160
/* Calculate the century (year/100). */
157161
century = temp / DAYS_PER_400_YEARS;
158162

ext/calendar/tests/gh16235.phpt

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

0 commit comments

Comments
 (0)