strptime returns random values for unparsed parts
| Bug #38524 | strptime returns random values for unparsed parts | ||||
|---|---|---|---|---|---|
| Submitted: | 2006-08-20 16:54 UTC | Modified: | 2006-08-20 18:27 UTC | ||
| From: | php at felixdd dot de | Assigned: | |||
| Status: | Closed | Package: | Date/time related | ||
| PHP Version: | 5.1.5 | OS: | Linux | ||
| Private report: | No | CVE-ID: | None | ||
[2006-08-20 16:54 UTC] php at felixdd dot de
Description:
------------
strptime returns random values for parts not included in the format string.
manpage of strptime says:
"In principle, this function does not initialize tm but only stores the values specified. This means that tm should be initialized before the call."
But this isn't done in ext/standard/datetime.c
neither in 5.1.5 nor in 5.2.0RC2
Reproduce code:
---------------
// only date, no time given
print_r(strptime('2006-08-20', '%Y-%m-%d'));
Expected result:
----------------
Array
(
[tm_sec] => 0
[tm_min] => 0
[tm_hour] => 0
[tm_mday] => 20
[tm_mon] => 7
[tm_year] => 106
[tm_wday] => 0
[tm_yday] => 231
[unparsed] =>
)
Actual result:
--------------
Array
(
[tm_sec] => 140252532 <-- random values each time called
[tm_min] => 13 <-- random values each time called
[tm_hour] => 1 <-- random values each time called
[tm_mday] => 20
[tm_mon] => 7
[tm_year] => 106
[tm_wday] => 0
[tm_yday] => 231
[unparsed] =>
)
Patches
Pull Requests
History
AllCommentsChangesGit/SVN commits
[2006-08-20 18:27 UTC] iliaa@php.net
[2016-12-12 01:31 UTC] microsoft at yahoo dot com