From 2b4c6c391cb9ab56e028dd5300aefdc18fea1d1b Mon Sep 17 00:00:00 2001 From: Andy Postnikov Date: Sat, 22 Aug 2020 02:44:48 +0300 Subject: [PATCH] Fix unixtojd long parameter parsing Also it fixes test on 32-bit armv7 and x86 - Test unixtojd() function : error conditions [ext/calendar/tests/unixtojd_error1.phpt] --- ext/calendar/cal_unix.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ext/calendar/cal_unix.c b/ext/calendar/cal_unix.c index e24ac56a25aa1..e1b203a616dec 100644 --- a/ext/calendar/cal_unix.c +++ b/ext/calendar/cal_unix.c @@ -28,16 +28,19 @@ 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) { RETURN_FALSE; + } else { + ts = (time_t)tl; } if (!(ta = php_localtime_r(&ts, &tmbuf))) {