Re: Re: com php-src: Fixed bug #67118 DateTime constructor crash with invalid data: NEWS ext/date/php_date.c ext/date/tests/bug67118.phpt

From: Date: Thu, 05 Jun 2014 05:54:07 +0000
Subject: Re: Re: com php-src: Fixed bug #67118 DateTime constructor crash with invalid data: NEWS ext/date/php_date.c ext/date/tests/bug67118.phpt
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-74750@lists.php.net to get a copy of this message
> Prior to this fix, no check for php_date_initialize() was done, Fix proposal attached Notice, bug67118.phpt is not ok, as it doesn't reproduce the segfault which is supposed to be fixed... With this patch, reproducer attached in the bug report doesn't segfault and now raise an exception: Warning: date_format(): The DateTime object has not been correctly initialized by its constructor in /dev/shm/php-5.6.0beta4/test.php on line 13 Remi.

diff -up ext/date/php_date.c.old ext/date/php_date.c --- ext/date/php_date.c.old 2014-06-05 07:42:56.431491483 +0200 +++ ext/date/php_date.c 2014-06-05 07:48:08.584734717 +0200 @@ -2582,6 +2582,8 @@ PHPAPI int php_date_initialize(php_date_ err->error_messages[0].position, err->error_messages[0].character, err->error_messages[0].message); } if (err && err->error_count) { + timelib_time_dtor(dateobj->time); + dateobj->time = 0; return 0; } @@ -2730,7 +2732,7 @@ 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)) { 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()); + //ZVAL_NULL(getThis()); } } zend_restore_error_handling(&error_handling TSRMLS_CC);
« previous php.internals (#74750) next »