Skip to content

Commit 35325ca

Browse files
committed
Fix GH-16258 overflow on jddayofweek argument.
1 parent 6d9903f commit 35325ca

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

ext/calendar/dow.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ int DayOfWeek(
3535
{
3636
int dow;
3737

38+
if ((sdn + 1) > INT_MAX) {
39+
return (0);
40+
}
41+
3842
dow = (sdn + 1) % 7;
3943
if (dow >= 0) {
4044
return (dow);

ext/calendar/tests/bug53574_2.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ array(9) {
2525
["year"]=>
2626
int(0)
2727
["dow"]=>
28-
int(3)
28+
int(0)
2929
["abbrevdayname"]=>
3030
string(3) "Wed"
3131
["dayname"]=>

ext/calendar/tests/gh16258.phpt

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

0 commit comments

Comments
 (0)