php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #23071 when trying to use the T flag in date it will crash if DST is in operation
Submitted: 2003-04-06 09:46 UTC Modified: 2003-04-06 17:43 UTC
From: scottmacvicar at ntlworld dot com Assigned:
Status: Closed Package: Date/time related
PHP Version: 4.3.2RC1 OS: Windows XP
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: scottmacvicar at ntlworld dot com
New email:
PHP Version: OS:

 

 [2003-04-06 09:46 UTC] scottmacvicar at ntlworld dot com
on windows this will crash Apache 2.0.45 using PHP built from this morning. tname[1] value is BST but tname[0] value is GMT Standard Time.

<?php
date('T');
?>

patch is as follows

--- datetime.c  Sun Feb  9 17:11:00 2003
+++ datetime.c.patched  Sun Apr  6 10:41:52 2003
@@ -540,7 +540,11 @@
 #if HAVE_TM_ZONE
                                strcat(Z_STRVAL_P(return_value), ta->tm_zone);
 #elif HAVE_TZNAME
-                               strcat(Z_STRVAL_P(return_value), tname[0]);
+                               if (ta->tm_isdst > 0 ) {
+                                       strcat(Z_STRVAL_P(return_value), tname[1]);
+                               } else {
+                                       strcat(Z_STRVAL_P(return_value), tname[0]);
+                               }
 #endif
                                break;
                        case 'B':       /* Swatch Beat a.k.a. Internet Time */

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-04-06 17:18 UTC] scottmacvicar at ntlworld dot com
bug23071.phpt

--TEST--
date('T') causes crash when DST is in effect and the DST timezone name is shorter than original timezone name
--SKIPIF--
<?php
	if (!date('I')) die('DST not in effect');
?>
--FILE--
<?php
	var_dump(date('T'));
?>
--EXPECT--
string(3) "BST"
 [2003-04-06 17:43 UTC] sniper@php.net
This bug has been fixed in CVS.

In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at http://snaps.php.net/.
 
In case this was a documentation problem, the fix will show up soon at
http://www.php.net/manual/.

In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites in short time.
 
Thank you for the report, and for helping us make PHP better.


Thanks for the patch. (I applied a little bit simpler version though :)

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 16:01:29 2024 UTC