php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #67274 DateTime constructor crash with invalid data
Submitted: 2014-05-14 09:23 UTC Modified: 2014-12-17 17:51 UTC
From: arjen at react dot com Assigned: kalle (profile)
Status: Closed Package: Date/time related
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: arjen at react dot com
New email:
PHP Version: OS:

 

 [2014-05-14 09:23 UTC] arjen at react dot com
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.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-06-20 10:00 UTC] arjen at react dot com
Fixed in in 5.6.0rc1: http://3v4l.org/FeE0n#v560rc1
Commit in https://bugs.php.net/bug.php?id=67118
 [2014-12-17 17:51 UTC] kalle@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: kalle
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 16:01:29 2024 UTC