diff options
| author | Ondřej Surý <ondrej@sury.org> | 2014-05-05 11:21:23 +0200 |
|---|---|---|
| committer | Ondřej Surý <ondrej@sury.org> | 2014-05-05 11:21:23 +0200 |
| commit | 4bbffbee21093458feadd96f93b96d4627461cff (patch) | |
| tree | d316b17d64aede352ae0a336c23238b8756004e6 /ext/date | |
| parent | 9566c3fcaf4cfaa866ea395ee5d1a480785fef0d (diff) | |
| download | php-4bbffbee21093458feadd96f93b96d4627461cff.tar.gz | |
New upstream version 5.6.0~beta2+dfsgupstream/5.6.0_beta2+dfsg
Diffstat (limited to 'ext/date')
| -rw-r--r-- | ext/date/php_date.c | 8 | ||||
| -rw-r--r-- | ext/date/tests/bug66721.phpt | 11 | ||||
| -rw-r--r-- | ext/date/tests/bug67118.phpt | 27 |
3 files changed, 45 insertions, 1 deletions
diff --git a/ext/date/php_date.c b/ext/date/php_date.c index 5852bb2ca..f81f87e4c 100644 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@ -2729,7 +2729,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); } @@ -2814,6 +2816,10 @@ static int php_date_initialize_from_hash(zval **return_value, php_date_obj **dat tzi = php_date_parse_tzfile(Z_STRVAL_PP(z_timezone), DATE_TIMEZONEDB TSRMLS_CC); + if (tzi == NULL) { + return 0; + } + ALLOC_INIT_ZVAL(tmp_obj); tzobj = zend_object_store_get_object(php_date_instantiate(date_ce_timezone, tmp_obj TSRMLS_CC) TSRMLS_CC); tzobj->type = TIMELIB_ZONETYPE_ID; diff --git a/ext/date/tests/bug66721.phpt b/ext/date/tests/bug66721.phpt new file mode 100644 index 000000000..480671243 --- /dev/null +++ b/ext/date/tests/bug66721.phpt @@ -0,0 +1,11 @@ +--TEST-- +Test for bug #66721: __wakeup of DateTime segfaults when invalid object data is supplied +--CREDITS-- +Boro Sitnikovski <buritomath@yahoo.com> +--FILE-- +<?php +$y = 'O:8:"DateTime":3:{s:4:"date";s:19:"2014-02-15 02:00:51";s:13:"timezone_type";i:3;s:8:"timezone";s:10:"1234567890";}'; +var_dump(unserialize($y)); +?> +--EXPECTF-- +Fatal error: Invalid serialization data for DateTime object in %s on line %d diff --git a/ext/date/tests/bug67118.phpt b/ext/date/tests/bug67118.phpt new file mode 100644 index 000000000..637175764 --- /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 +{ + public function __construct($time = '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 |
