com php-src: Fixed bug #67118 DateTime constructor crash with invalid data: NEWS ext/date/php_date.c ext/date/tests/bug6711 8.phpt
| From: | Anatol Belski | Date: | Fri, 25 Apr 2014 15:23:26 +0000 |
| Subject: | com php-src: Fixed bug #67118 DateTime constructor crash with invalid data: NEWS ext/date/php_date.c ext/date/tests/bug6711 8.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-77147@lists.php.net to get a copy of this message | ||
Commit: c1aa9baf29d1a20fa60c1cef3979a80014f6677b
Author: Anatol Belski <ab@php.net> Fri, 25 Apr 2014 17:23:26 +0200
Parents: 03c703b8bd55679edf30fe17529fab0c2281b01f
Branches: PHP-5.4 PHP-5.5 PHP-5.6 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=c1aa9baf29d1a20fa60c1cef3979a80014f6677b
Log:
Fixed bug #67118 DateTime constructor crash with invalid data
Bugs:
https://bugs.php.net/67118
Changed paths:
M NEWS
M ext/date/php_date.c
A ext/date/tests/bug67118.phpt
Diff:
diff --git a/NEWS b/NEWS
index 26a1791..2212b03 100644
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,9 @@ PHP NEWS
by tempnam()). (Boro Sitnikovski)
. Fixed bug #67072 (Echoing unserialized "SplFileObject" crash). (Anatol)
+- Date:
+ . Fixed bug #67118 (DateTime constructor crash with invalid data). (Anatol)
+
- DOM:
. Fixed bug #67081 (DOMDocumentType->internalSubset returns entire DOCTYPE tag,
not only the subset). (Anatol)
diff --git a/ext/date/php_date.c b/ext/date/php_date.c
index 4a37961..d4058eb 100644
--- a/ext/date/php_date.c
+++ b/ext/date/php_date.c
@@ -2548,7 +2548,9 @@ PHP_METHOD(DateTime, __construct)
zend_replace_error_handling(EH_THROW, NULL, &error_handling TSRMLS_CC);
if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|sO!", &time_str,
&time_str_len, &timezone_object, date_ce_timezone)) {
- php_date_initialize(zend_object_store_get_object(getThis() TSRMLS_CC), time_str, time_str_len,
NULL, timezone_object, 1 TSRMLS_CC);
+ if (!php_date_initialize(zend_object_store_get_object(getThis() TSRMLS_CC), time_str,
time_str_len, NULL, timezone_object, 1 TSRMLS_CC)) {
+ ZVAL_NULL(getThis());
+ }
}
zend_restore_error_handling(&error_handling TSRMLS_CC);
}
diff --git a/ext/date/tests/bug67118.phpt b/ext/date/tests/bug67118.phpt
new file mode 100644
index 0000000..b10e9ea
--- /dev/null
+++ b/ext/date/tests/bug67118.phpt
@@ -0,0 +1,27 @@
+--TEST--
+Bug #67118 php-cgi crashes regularly on IIS 7
+--INI--
+date.timezone=Europe/Berlin
+--FILE--
+<?php
+class mydt extends datetime
+{
+ publi function __construct($tits\bug67118.phpte = 'now', $tz = NULL, $format = NULL)
+ {
+ if (!empty($tz) && !is_object($tz)) {
+ $tz = new DateTimeZone($tz);
+ }
+
+ @parent::__construct($time, $tz);
+ }
+
+};
+
+new mydt("Funktionsansvarig rådgivning och juridik", "UTC");
+--EXPECTF--
+Fatal error: Uncaught exception 'Exception' with message 'DateTime::__construct():
Failed to parse time string (Funktionsansvarig rådgivning och juridik) at position 0 (F): The
timezone could not be found in the database' in %sbug67118.php:%d
+Stack trace:
+#0 %sbug67118.php(%d): DateTime->__construct('Funktionsansvar...',
Object(DateTimeZone))
+#1 %sbug67118.php(%d): mydt->__construct('Funktionsansvar...', 'UTC')
+#2 {main}
+ thrown in %sbug67118.php on line %d