php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #37747 strtotime segfaults when given "nextyear"
Submitted: 2006-06-08 15:02 UTC Modified: 2006-06-08 16:30 UTC
From: php at stut dot net Assigned: derick
Status: Closed Package: Date/time related
PHP Version: 5CVS-2006-06-08 (CVS) OS: FreeBSD 5.4-RELEASE
Private report: No CVE-ID:
 [2006-06-08 15:02 UTC] php at stut dot net
Description:
------------
Segfault when giving strtotime "nextyear"

Reproduce code:
---------------
<?php
if (strtotime('2007-01-01') == strtotime('nextyear', strtotime('2006-01-01')))
        print "Success";
else
        print "Failure";
?>

Expected result:
----------------
Prints "Success"

Actual result:
--------------
Program terminated with signal 11, Segmentation fault.
Reading symbols from /lib/libcrypt.so.2...done.
Loaded symbols for /lib/libcrypt.so.2
Reading symbols from /usr/local/lib/libiconv.so.3...done.
Loaded symbols for /usr/local/lib/libiconv.so.3
Reading symbols from /lib/libm.so.3...done.
Loaded symbols for /lib/libm.so.3
Reading symbols from /usr/local/lib/libxml2.so.5...done.
Loaded symbols for /usr/local/lib/libxml2.so.5
Reading symbols from /lib/libz.so.2...done.
Loaded symbols for /lib/libz.so.2
Reading symbols from /lib/libc.so.5...done.
Loaded symbols for /lib/libc.so.5
Reading symbols from /libexec/ld-elf.so.1...done.
Loaded symbols for /libexec/ld-elf.so.1
#0  timelib_set_relative (ptr=0x0, amount=0, behavior=0, s=0xbfbfd240) at parse_date.re:594
594             switch (relunit->unit) {

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-06-08 16:20 UTC] judas dot iscariote at gmail dot com
Program received signal SIGSEGV, Segmentation fault.
timelib_set_relative (ptr=<value optimized out>, amount=0, behavior=0, s=0x7ffffffc5330) at parse_date.re:594
594             switch (relunit->unit) {
(gdb) bt
#0  timelib_set_relative (ptr=<value optimized out>, amount=0, behavior=0, s=0x7ffffffc5330) at parse_date.re:594
#1  0x000000000045de3e in timelib_strtotime (s=<value optimized out>, len=<value optimized out>, errors=0x7ffffffc53f0,
    tzdb=<value optimized out>) at parse_date.re:1378
#2  0x0000000000458c18 in zif_strtotime (ht=1, return_value=0x9d9e50, return_value_ptr=<value optimized out>,
    this_ptr=<value optimized out>, return_value_used=<value optimized out>)
    at /local/local/bodegon/php-debug/ext/date/php_date.c:945
#3  0x00000000005fb341 in zend_do_fcall_common_helper_SPEC (execute_data=0x7ffffffc5590) at zend_vm_execute.h:200
#4  0x00000000005f4efe in execute (op_array=0x9d9850) at zend_vm_execute.h:92
#5  0x00000000005c9beb in zend_eval_string (str=<value optimized out>, retval_ptr=0x0, string_name=<value optimized out>)
    at /local/local/bodegon/php-debug/Zend/zend_execute_API.c:1116
#6  0x00000000005c9d78 in zend_eval_string_ex (str=<value optimized out>, retval_ptr=<value optimized out>,
    string_name=<value optimized out>, handle_exceptions=1) at /local/local/bodegon/php-debug/Zend/zend_execute_API.c:1150
#7  0x00000000006733f0 in main (argc=3, argv=0x7ffffffc5a78) at /local/local/bodegon/php-debug/sapi/cli/php_cli.c:1128

php -v 
PHP 5.2.0-dev (cli) (built: Jun  8 2006 12:09:46) (DEBUG)


test case.

--TEST--
Bug #37747 strtotime segfaults when given "nextyear"
--FILE--
<?php
echo strtotime('nextyear',strtotime('2006-01-01'));
?>
--EXPECT--
1149811500
 [2006-06-08 16:30 UTC] derick@php.net
This bug has been fixed in CVS.

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/.
 
Thank you for the report, and for helping us make PHP better.
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Fri Apr 18 05:03:21 2014 UTC