php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #48611 strtotime very slow with large values
Submitted: 2009-06-19 19:13 UTC Modified: 2009-06-28 01:00 UTC
Votes:2
Avg. Score:3.5 ± 0.5
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:2 (100.0%)
From: evert at rooftopsolutions dot nl Assigned:
Status: No Feedback Package: Date/time related
PHP Version: 5.2.10 OS: Debian
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: evert at rooftopsolutions dot nl
New email:
PHP Version: OS:

 

 [2009-06-19 19:13 UTC] evert at rooftopsolutions dot nl
Description:
------------
strtotime is very slow with very large values.



Reproduce code:
---------------
php -r "echo strtotime('-50000000000 days');"

also, to clearly see this function has O(n) instead of O(1) complexity.

for x in {1..40}; do php -r "echo $x, \"\t\", pow ( 2, $x ), \"\t\", strtotime ( ( -1 * pow ( 2, $x ) ) . ' days' ), \"\n\";" 2> /dev/null; done;


Regardless of the fact you won't often work with dates 130 million years ago, this could be used to trigger a dos-like attack.

Expected result:
----------------
Quick results

Actual result:
--------------
veryyy slow results :)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-06-20 01:24 UTC] scottmac@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.3-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/

Pretty sure this is fixed in 5.3
 [2009-06-28 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Thu Dec 02 08:03:36 2021 UTC