summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnatol Belski <ab@php.net>2016-07-01 18:45:02 +0200
committerAnatol Belski <ab@php.net>2016-07-01 18:45:02 +0200
commitdad2a3ef67e94a16f1389828cea7ee5a6c55384c (patch)
tree323595a8b6117af8122b20bcf49f9d58ff26d35e
parentd1dd474ff903c2b7f6839e0ccba3e08fd47a1649 (diff)
parentc9fa39da5eaf87a55cef75f8412ed07040a7b499 (diff)
downloadphp-git-dad2a3ef67e94a16f1389828cea7ee5a6c55384c.tar.gz
Merge branch 'PHP-7.0'
* PHP-7.0: update NEWS Fixed bug #72498 variant_date_from_timestamp null dereference
-rw-r--r--ext/com_dotnet/com_variant.c7
-rw-r--r--ext/com_dotnet/tests/bug72498.phpt16
2 files changed, 23 insertions, 0 deletions
diff --git a/ext/com_dotnet/com_variant.c b/ext/com_dotnet/com_variant.c
index 58ba3f154c..6a5dc9dacb 100644
--- a/ext/com_dotnet/com_variant.c
+++ b/ext/com_dotnet/com_variant.c
@@ -1007,6 +1007,13 @@ PHP_FUNCTION(variant_date_from_timestamp)
tzset();
ttstamp = timestamp;
tmv = localtime(&ttstamp);
+#if ZEND_ENABLE_ZVAL_LONG64
+ /* Invalid after 23:59:59, December 31, 3000, UTC */
+ if (!tmv) {
+ php_error_docref(NULL, E_WARNING, "Invalid timestamp " ZEND_LONG_FMT, timestamp);
+ RETURN_FALSE;
+ }
+#endif
memset(&systime, 0, sizeof(systime));
systime.wDay = tmv->tm_mday;
diff --git a/ext/com_dotnet/tests/bug72498.phpt b/ext/com_dotnet/tests/bug72498.phpt
new file mode 100644
index 0000000000..e155735ba5
--- /dev/null
+++ b/ext/com_dotnet/tests/bug72498.phpt
@@ -0,0 +1,16 @@
+--TEST--
+Bug #72498 variant_date_from_timestamp null dereference
+--SKIPIF--
+<?php # vim:ft=php
+if (!extension_loaded("com_dotnet")) print "skip COM/.Net support not present";
+if (PHP_INT_SIZE != 8) print "skip 64-bit only";
+?>
+--FILE--
+<?php
+
+$v1 = PHP_INT_MAX;
+var_dump(variant_date_from_timestamp($v1));
+?>
+--EXPECTF--
+Warning: variant_date_from_timestamp(): Invalid timestamp %d in %sbug72498.php on line %d
+bool(false)