Merge branch 'PHP-7.3' into PHP-7.4

* PHP-7.3:
  Fix #80185: jdtounix() fails after 2037
This commit is contained in:
Christoph M. Becker 2020-10-07 13:24:55 +02:00
commit 9dddfbe755
4 changed files with 41 additions and 2 deletions

3
NEWS
View file

@ -9,6 +9,9 @@ PHP NEWS
(cmb)
. Fixed bug #80126 (Covariant return types failing compilation). (Nikita)
- Calendar:
. Fixed bug #80185 (jdtounix() fails after 2037). (cmb)
- MySQLnd:
. Fixed bug #80115 (mysqlnd.debug doesn't recognize absolute paths with
slashes). (cmb)

View file

@ -23,6 +23,8 @@
#include "sdncal.h"
#include <time.h>
#define SECS_PER_DAY (24 * 3600)
/* {{{ proto int unixtojd([int timestamp])
Convert UNIX timestamp to Julian Day */
PHP_FUNCTION(unixtojd)
@ -62,10 +64,10 @@ PHP_FUNCTION(jdtounix)
}
uday -= 2440588 /* J.D. of 1.1.1970 */;
if (uday < 0 || uday > 24755) { /* before beginning of unix epoch or behind end of unix epoch */
if (uday < 0 || uday > ZEND_LONG_MAX / SECS_PER_DAY) { /* before beginning of unix epoch or greater than representable */
RETURN_FALSE;
}
RETURN_LONG(uday * 24 * 3600);
RETURN_LONG(uday * SECS_PER_DAY);
}
/* }}} */

View file

@ -0,0 +1,17 @@
--TEST--
Bug #80185 (jdtounix() fails after 2037)
--SKIPIF--
<?php
if (!extension_loaded('calendar')) die('skip ext/calendar required');
if (PHP_INT_SIZE != 8) die("skip for 64bit platforms only");
?>
--FILE--
<?php
var_dump(jdtounix(2465712));
var_dump(jdtounix(PHP_INT_MAX / 86400 + 2440588));
var_dump(jdtounix(PHP_INT_MAX / 86400 + 2440589));
?>
--EXPECT--
int(2170713600)
int(9223372036854720000)
bool(false)

View file

@ -0,0 +1,17 @@
--TEST--
Bug #80185 (jdtounix() fails after 2037)
--SKIPIF--
<?php
if (!extension_loaded('calendar')) die('skip ext/calendar required');
if (PHP_INT_SIZE != 4) die("skip for 32bit platforms only");
?>
--FILE--
<?php
var_dump(jdtounix(2465712));
var_dump(jdtounix(PHP_INT_MAX / 86400 + 2440588));
var_dump(jdtounix(PHP_INT_MAX / 86400 + 2440589));
?>
--EXPECT--
bool(false)
int(2147472000)
bool(false)