]> granicus.if.org Git - php/commitdiff
Fixed bug #72498 variant_date_from_timestamp null dereference
authorAnatol Belski <ab@php.net>
Fri, 1 Jul 2016 16:41:50 +0000 (18:41 +0200)
committerAnatol Belski <ab@php.net>
Fri, 1 Jul 2016 16:41:50 +0000 (18:41 +0200)
ext/com_dotnet/com_variant.c
ext/com_dotnet/tests/bug72498.phpt [new file with mode: 0644]

index 58ba3f154c7f80ff8d6c768f2ea17c509d824ca6..6a5dc9dacb286d166767090f3ff3bcf80c2bc7cf 100644 (file)
@@ -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 (file)
index 0000000..e155735
--- /dev/null
@@ -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)