Skip to content

Commit 71e5d77

Browse files
committed
Merge branch 'PHP-8.3' into PHP-8.4
2 parents f815310 + d89cf7b commit 71e5d77

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
@@ -9,6 +9,9 @@ PHP NEWS
99
bypassable due to the environment variable collision). (CVE-2024-8927)
1010
(nielsdos)
1111

12+
- Calendar:
13+
. Fixed GH-16240: jdtounix overflow on argument value. (David Carlier)
14+
1215
- CLI:
1316
. Fixed bug GH-16137: duplicate http headers when set several times by
1417
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)