php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #2397 Segmentation fault when using date with 'g' or 'G' in the format string
Submitted: 1999-09-28 12:52 UTC Modified: 1999-09-28 13:32 UTC
From: venkat at manton dot com Assigned:
Status: Closed Package: Reproducible Crash
PHP Version: 3.0.12 OS: Linux v2.0.36
Private report: No CVE-ID: None
 [1999-09-28 12:52 UTC] venkat at manton dot com
PHP running as an Apache v1.3.9 module.

The following script:

<?php
$current_time = date("M j Y g:i A");
?>

causes a segmentation fault of the process running the script if it is run when the hour of the local time is 2 digits (ie between 10am and 12pm and 10pm and 12am). 

The problem can be traced back to the _php3_date() function in functions/datetime.c. The switch case for computing the size of the string required to hold the formatted date does not increment the size by 2 for the 'g' and 'G' cases. It is incorrectly incremented by 1.

Venkat

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1999-09-28 13:32 UTC] rasmus at cvs dot php dot net
This was fixed in CVS a while ago and will be in 3.0.13.
 [2023-04-29 09:22 UTC] git@php.net
Automatic comment on behalf of FatherShawn (author) and web-flow (committer)
Revision: https://github.com/php/doc-en/commit/010542d1dcb9b1d5cd397a77ed580e50de25aca7
Log: Fix #2397: Bring reserved.xml in sync with RFC  (#2398)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Apr 28 12:01:28 2024 UTC