Bug #67274 [NEW]: DateTime constructor crash with invalid data
| From: | arjen at react dot com | Date: | Wed, 14 May 2014 09:23:33 +0000 |
| Subject: | Bug #67274 [NEW]: DateTime constructor crash with invalid data | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-185818@lists.php.net to get a copy of this message | ||
From: arjen at react dot com
Operating system:
PHP version: Irrelevant
Package: Date/time related
Bug Type: Bug
Bug description:DateTime constructor crash with invalid data
Description:
------------
Only partially solved in https://bugs.php.net/bug.php?id=67118
$this is unset (see https://bugs.php.net/bug.php?id=67179 for bug about
this) but corrupted internal state still intact. Catching exception and
calling parent::format() results in a segfault.
See http://3v4l.org/FeE0n#v536
Test script:
---------------
<?php
class DateTimeCustom extends DateTime
{
public function __construct($datetime, $timezone = null)
{
try
{
parent::__construct($datetime, $timezone);
}
catch (Exception $e)
{
var_dump($this, parent::getLastErrors(), parent::format('c'));
}
}
}
$date = new DateTimeCustom("sunday 09 blabla 2001 103:46:40 CEST");
Expected result:
----------------
Result for 5.3.0 - 5.3.5 is expected:
Warning: DateTime::format(): The DateTime object has not been correctly
initialized by its constructor in /in/FeE0n on line 15
object(DateTimeCustom)#1 (0) {
}
bool(false)
bool(false)
Actual result:
--------------
Segfault.
--
Edit bug report at https://bugs.php.net/bug.php?id=67274&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=67274&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=67274&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=67274&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=67274&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=67274&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=67274&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=67274&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=67274&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=67274&r=support
Expected behavior: https://bugs.php.net/fix.php?id=67274&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=67274&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=67274&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=67274&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=67274&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=67274&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=67274&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=67274&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=67274&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=67274&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=67274&r=mysqlcfg