Skip to content

Commit 5c6f18b

Browse files
committed
Merge branch 'PHP-8.4'
2 parents 27a1d69 + f7a508c commit 5c6f18b

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

ext/calendar/gregor.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,11 @@ void SdnToGregorian(
162162

163163
/* Calculate the year and day of year (1 <= dayOfYear <= 366). */
164164
temp = ((temp % DAYS_PER_400_YEARS) / 4) * 4 + 3;
165+
166+
if (century > ((INT_MAX / 100) - (temp / DAYS_PER_4_YEARS))) {
167+
goto fail;
168+
}
169+
165170
year = (century * 100) + (temp / DAYS_PER_4_YEARS);
166171
dayOfYear = (temp % DAYS_PER_4_YEARS) / 4 + 1;
167172

ext/calendar/tests/gh16834.phpt

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
--TEST--
2+
GH-16834 (cal_from_jd from julian_day argument)
3+
--EXTENSIONS--
4+
calendar
5+
--SKIPIF--
6+
<?php if (PHP_INT_SIZE != 8) die("skip for 64bit platforms only"); ?>
7+
--FILE--
8+
<?php
9+
var_dump(cal_from_jd(076545676543223, CAL_GREGORIAN));
10+
?>
11+
--EXPECTF--
12+
array(9) {
13+
["date"]=>
14+
string(5) "0/0/0"
15+
["month"]=>
16+
int(0)
17+
["day"]=>
18+
int(0)
19+
["year"]=>
20+
int(0)
21+
["dow"]=>
22+
int(%d)
23+
["abbrevdayname"]=>
24+
string(3) "%s"
25+
["dayname"]=>
26+
string(9) "%s"
27+
["abbrevmonth"]=>
28+
string(0) ""
29+
["monthname"]=>
30+
string(0) ""
31+
}

0 commit comments

Comments
 (0)