Skip to content

Commit e3fe9a9

Browse files
committed
Merge branch 'PHP-8.3' into PHP-8.4
2 parents 2577e3a + 2ccd2b0 commit e3fe9a9

File tree

5 files changed

+41
-1
lines changed

5 files changed

+41
-1
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.4.10
44

5+
- Calendar:
6+
. Fixed jewishtojd overflow on year argument. (David Carlier)
7+
58
- Core:
69
. Fixed bug GH-18833 (Use after free with weakmaps dependent on destruction
710
order). (Daniil Gentili)

ext/calendar/calendar.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,11 @@ PHP_FUNCTION(jewishtojd)
490490
RETURN_THROWS();
491491
}
492492

493+
if (ZEND_LONG_EXCEEDS_INT(year)) {
494+
zend_argument_value_error(3, "must be between %d and %d", INT_MIN, INT_MAX);
495+
RETURN_THROWS();
496+
}
497+
493498
RETURN_LONG(JewishToSdn(year, month, day));
494499
}
495500
/* }}} */

ext/calendar/jewish.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,7 @@ zend_long JewishToSdn(
710710
int yearLength;
711711
int lengthOfAdarIAndII;
712712

713-
if (year <= 0 || day <= 0 || day > 30) {
713+
if (year <= 0 || year >= 6000 || day <= 0 || day > 30) {
714714
return (0);
715715
}
716716
switch (month) {

ext/calendar/tests/gh16234_2.phpt

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

ext/calendar/tests/gh16234_2_64.phpt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
--TEST--
2+
GH-16234 jewishtojd overflow on year argument
3+
--EXTENSIONS--
4+
calendar
5+
--SKIPIF--
6+
<?php
7+
if (PHP_INT_SIZE == 4) {
8+
die("skip this test is for 64bit platform only");
9+
}
10+
?>
11+
--FILE--
12+
<?php
13+
try {
14+
jewishtojd(10, 6, PHP_INT_MIN);
15+
} catch (\ValueError $e) {
16+
echo $e->getMessage(), PHP_EOL;
17+
}
18+
?>
19+
--EXPECTF--
20+
jewishtojd(): Argument #3 ($year) must be between %i and %d
21+

0 commit comments

Comments
 (0)