From: Andy Postnikov Date: Fri, 21 Aug 2020 23:44:48 +0000 (+0300) Subject: Fix #80007: Potential type confusion in unixtojd() parameter parsing X-Git-Tag: php-7.3.23RC1~31 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b2a33ab06bab4f2d79634e294632bebebd04acdb;p=php 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 GH-6033 --- diff --git a/NEWS b/NEWS index 4748996c26..49ac4c5a69 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,9 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? ??? ????, PHP 7.3.23 +- Calendar: + . Fixed bug #80007 (Potential type confusion in unixtojd() parameter parsing). + (Andy Postnikov) 03 Sep 2020, PHP 7.3.22 diff --git a/ext/calendar/cal_unix.c b/ext/calendar/cal_unix.c index a8e81eb541..da6a184e6c 100644 --- a/ext/calendar/cal_unix.c +++ b/ext/calendar/cal_unix.c @@ -28,15 +28,18 @@ PHP_FUNCTION(unixtojd) { time_t ts = 0; + zend_long tl = 0; struct tm *ta, tmbuf; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &ts) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &tl) == FAILURE) { return; } - if (!ts) { + if (!tl) { ts = time(NULL); - } else if (ts < 0) { + } else if (tl >= 0) { + ts = (time_t) tl; + } else { RETURN_FALSE; }