Skip to content

Commit b2a33ab

Browse files
andypostcmb69
authored andcommitted
Fix #80007: Potential type confusion in unixtojd() parameter parsing
Also it fixes test on 32-bit armv7 and x86 - Test unixtojd() function : error conditions [ext/calendar/tests/unixtojd_error1.phpt] Closes phpGH-6033
1 parent 46d62e5 commit b2a33ab

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

NEWS

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ PHP NEWS
22
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
33
?? ??? ????, PHP 7.3.23
44

5+
- Calendar:
6+
. Fixed bug #80007 (Potential type confusion in unixtojd() parameter parsing).
7+
(Andy Postnikov)
58

69
03 Sep 2020, PHP 7.3.22
710

ext/calendar/cal_unix.c

+6-3
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,18 @@
2828
PHP_FUNCTION(unixtojd)
2929
{
3030
time_t ts = 0;
31+
zend_long tl = 0;
3132
struct tm *ta, tmbuf;
3233

33-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &ts) == FAILURE) {
34+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &tl) == FAILURE) {
3435
return;
3536
}
3637

37-
if (!ts) {
38+
if (!tl) {
3839
ts = time(NULL);
39-
} else if (ts < 0) {
40+
} else if (tl >= 0) {
41+
ts = (time_t) tl;
42+
} else {
4043
RETURN_FALSE;
4144
}
4245

0 commit comments

Comments
 (0)