summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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)