Skip to content

Commit 3455848

Browse files
committed
Fixed bug #72498 variant_date_from_timestamp null dereference
1 parent 9b8f1d6 commit 3455848

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

ext/com_dotnet/com_variant.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,6 +1007,13 @@ PHP_FUNCTION(variant_date_from_timestamp)
10071007
tzset();
10081008
ttstamp = timestamp;
10091009
tmv = localtime(&ttstamp);
1010+
#if ZEND_ENABLE_ZVAL_LONG64
1011+
/* Invalid after 23:59:59, December 31, 3000, UTC */
1012+
if (!tmv) {
1013+
php_error_docref(NULL, E_WARNING, "Invalid timestamp " ZEND_LONG_FMT, timestamp);
1014+
RETURN_FALSE;
1015+
}
1016+
#endif
10101017
memset(&systime, 0, sizeof(systime));
10111018

10121019
systime.wDay = tmv->tm_mday;

ext/com_dotnet/tests/bug72498.phpt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
--TEST--
2+
Bug #72498 variant_date_from_timestamp null dereference
3+
--SKIPIF--
4+
<?php # vim:ft=php
5+
if (!extension_loaded("com_dotnet")) print "skip COM/.Net support not present";
6+
if (PHP_INT_SIZE != 8) print "skip 64-bit only";
7+
?>
8+
--FILE--
9+
<?php
10+
11+
$v1 = PHP_INT_MAX;
12+
var_dump(variant_date_from_timestamp($v1));
13+
?>
14+
--EXPECTF--
15+
Warning: variant_date_from_timestamp(): Invalid timestamp %d in %sbug72498.php on line %d
16+
bool(false)

0 commit comments

Comments
 (0)