Skip to content

Commit d89cf7b

Browse files
committed
Merge branch 'PHP-8.2' into PHP-8.3
2 parents 4e23d39 + f4d2dd0 commit d89cf7b

File tree

3 files changed

+27
-3
lines changed

3 files changed

+27
-3
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ PHP NEWS
22
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
33
?? ??? ????, PHP 8.3.13
44

5+
- Calendar:
6+
. Fixed GH-16240: jdtounix overflow on argument value. (David Carlier)
7+
58
- CLI:
69
. Fixed bug GH-16137: duplicate http headers when set several times by
710
the client. (David Carlier)

ext/calendar/cal_unix.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,13 @@ PHP_FUNCTION(jdtounix)
6060
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &uday) == FAILURE) {
6161
RETURN_THROWS();
6262
}
63-
uday -= 2440588 /* J.D. of 1.1.1970 */;
64-
65-
if (uday < 0 || uday > ZEND_LONG_MAX / SECS_PER_DAY) { /* before beginning of unix epoch or greater than representable */
63+
if (uday < 2440588 || (uday - 2440588) > (ZEND_LONG_MAX / SECS_PER_DAY)) { /* before beginning of unix epoch or greater than representable */
6664
zend_value_error("jday must be between 2440588 and " ZEND_LONG_FMT, ZEND_LONG_MAX / SECS_PER_DAY + 2440588);
6765
RETURN_THROWS();
6866
}
6967

68+
uday -= 2440588 /* J.D. of 1.1.1970 */;
69+
7070
RETURN_LONG(uday * SECS_PER_DAY);
7171
}
7272
/* }}} */

ext/calendar/tests/gh16231.phpt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
--TEST--
2+
GH-16231 (jdtounix argument overflow)
3+
--EXTENSIONS--
4+
calendar
5+
--FILE--
6+
<?php
7+
try {
8+
jdtounix(PHP_INT_MIN);
9+
} catch (\ValueError $e) {
10+
echo $e->getMessage() . PHP_EOL;
11+
}
12+
13+
try {
14+
jdtounix(240587);
15+
} catch (\ValueError $e) {
16+
echo $e->getMessage();
17+
}
18+
?>
19+
--EXPECTF--
20+
jday must be between 2440588 and %d
21+
jday must be between 2440588 and %d

0 commit comments

Comments
 (0)