We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 91eda57 + a0c7550 commit 3942972Copy full SHA for 3942972
ext/calendar/gregor.c
@@ -148,11 +148,15 @@ void SdnToGregorian(
148
int dayOfYear;
149
150
if (sdn <= 0 ||
151
- sdn > (LONG_MAX - 4 * GREGOR_SDN_OFFSET) / 4) {
+ sdn > (ZEND_LONG_MAX - 4 * GREGOR_SDN_OFFSET) / 4) {
152
goto fail;
153
}
154
temp = (sdn + GREGOR_SDN_OFFSET) * 4 - 1;
155
156
+ if (temp < 0 || (temp / DAYS_PER_400_YEARS) > INT_MAX) {
157
+ goto fail;
158
+ }
159
+
160
/* Calculate the century (year/100). */
161
century = temp / DAYS_PER_400_YEARS;
162
ext/calendar/tests/gh16235.phpt
@@ -0,0 +1,11 @@
1
+--TEST--
2
+GH-16235 (jdtogregorian overflow on argument)
3
+--EXTENSIONS--
4
+calendar
5
+--FILE--
6
+<?php
7
+jdtogregorian(536838867);
8
+echo "DONE";
9
+?>
10
+--EXPECT--
11
+DONE
0 commit comments