php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #23457 PHP crashes
Submitted: 2003-05-02 17:52 UTC Modified: 2003-05-09 08:02 UTC
From: xdanny at email dot cz Assigned:
Status: No Feedback Package: Date/time related
PHP Version: 4.3.2RC1 OS: win32
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: xdanny at email dot cz
New email:
PHP Version: OS:

 

 [2003-05-02 17:52 UTC] xdanny at email dot cz
My environment is PHP 4.3.2 RC1 on W2K with IIS ISAPI module. Don't exactly know - I only suppose that this problem is related more to Date function than to IIS - i don't have enough systems to test on. In normal situation you should have all constants set up, thats true, but if any of your customers run wrong script on your server machine, he could cause crash of whole IIS.

The symptom is simple: If you use not defined constant in date format parameter of Date() function it causes Access violation and crashes IIS.
PHP has encountered an Access Violation at 014FD4EB

A script causing PHP

<?php

//define(DATEFORMAT, 'Y/m/d');

$timestamp = Time();
$today = Date(DATEFORMAT, $timestamp); 

echo "Hi, today is $today";


?>

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-05-04 05:13 UTC] nicos@php.net
I have the same problem with PHP5:

[Sun May  4 - 12:08:17 - nicos ~]$ php
<?php

//define(DATEFORMAT, 'Y/m/d');

$timestamp = Time();
$today = Date(DATEFORMAT, $timestamp);

echo "Hi, today is $today";


?>

Hi, today is SunPMCESTEMay+0200RMayPMCEST
[Sun May  4 - 12:08:19 - nicos ~]$

PHP 5.0.0-dev (cli) (built: Apr 27 2003 15:59:15)
Copyright (c) 1997-2003 The PHP Group
Zend Engine v2.0.0-dev, Copyright (c) 1998-2003 Zend Technologies


Same with :
PHP 4.3.2-RC1 (cli) (built: May  1 2003 19:59:00)
Copyright (c) 1997-2003 The PHP Group
Zend Engine v1.3.0, Copyright (c) 1998-2003 Zend Technologies

Shouldn't it print an E_FATAL when we're using an undefined constant?
 [2003-05-04 05:17 UTC] nicos@php.net
This probably happens because the engine accepts unquoted word when it's alone. It takes it as 
$today = date('DATEFORMAT',$timestamp);

Yes this is ugly but I don't think this can be changed if we dont want to break BC again.

Btw if you try 
$today = date(DATEFORMAT LOL,$timestamp);
It will parser error but not with only one word.

 [2003-05-04 05:26 UTC] nicos@php.net
Note that you will be get a notice if you use error_reporting(E_ALL);
:
Notice: Use of undefined constant DATEFORMAT - assumed 'DATEFORMAT' in - on line 3
-(3) : Notice - Use of undefined constant DATEFORMAT - assumed 'DATEFORMAT'

 [2003-05-04 05:27 UTC] derick@php.net
It's not verified on Linux where it doesnt crash. It does crash on Windows though, but not when run from within the MS VC debugger...
 [2003-05-09 08:02 UTC] sniper@php.net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.


 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC