summaryrefslogtreecommitdiff
path: root/ext/date/tests
diff options
context:
space:
mode:
authorChristoph M. Becker <cmbecker69@gmx.de>2019-12-23 14:42:54 +0100
committerChristoph M. Becker <cmbecker69@gmx.de>2020-01-03 14:31:03 +0100
commitb48f2625b57f70eea858033e623e6bf13b595e3b (patch)
tree2b31d1e68a118561431ae485b7993b7deee88365 /ext/date/tests
parent0cecf83b264cbbb5683ab8a843cc4a4d9c294644 (diff)
downloadphp-git-b48f2625b57f70eea858033e623e6bf13b595e3b.tar.gz
Fix #79015: undefined-behavior in php_date.c
We check that the given microsecond fraction is in the valid range [0, 1000000[, and otherwise mark it as invalid. We also drop the useless do loop; a plain block is sufficient here.
Diffstat (limited to 'ext/date/tests')
-rw-r--r--ext/date/tests/bug79015.phpt42
1 files changed, 42 insertions, 0 deletions
diff --git a/ext/date/tests/bug79015.phpt b/ext/date/tests/bug79015.phpt
new file mode 100644
index 0000000000..5ebb13832b
--- /dev/null
+++ b/ext/date/tests/bug79015.phpt
@@ -0,0 +1,42 @@
+--TEST--
+Bug #79015 (undefined-behavior in php_date.c)
+--FILE--
+<?php
+$payload = 'O:12:"DateInterval":16:{s:1:"y";i:1;s:1:"m";i:0;s:1:"d";i:4;s:1:"h";i:0;s:1:"i";i:0;s:1:"s";i:0;s:1:"f";i:9999999999990;s:7:"weekday";i:0;s:16:"weekday_behavior";i:0;s:17:"first_last_day_of";i:0;s:6:"invert";i:0;s:4:"days";b:0;s:12:"special_type";i:0;s:14:"special_amount";i:0;s:21:"have_weekday_relative";i:0;s:21:"have_special_relative";i:0;}';
+var_dump(unserialize($payload));
+?>
+--EXPECTF--
+object(DateInterval)#%d (16) {
+ ["y"]=>
+ int(1)
+ ["m"]=>
+ int(0)
+ ["d"]=>
+ int(4)
+ ["h"]=>
+ int(0)
+ ["i"]=>
+ int(0)
+ ["s"]=>
+ int(0)
+ ["f"]=>
+ float(-1)
+ ["weekday"]=>
+ int(0)
+ ["weekday_behavior"]=>
+ int(0)
+ ["first_last_day_of"]=>
+ int(0)
+ ["invert"]=>
+ int(0)
+ ["days"]=>
+ bool(false)
+ ["special_type"]=>
+ int(0)
+ ["special_amount"]=>
+ int(0)
+ ["have_weekday_relative"]=>
+ int(0)
+ ["have_special_relative"]=>
+ int(0)
+}