diff options
author | David A Ramos <daramos@gustav.stanford.edu> | 2010-07-27 13:10:15 +0200 |
---|---|---|
committer | Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> | 2010-07-27 13:10:15 +0200 |
commit | 85b7ea33088fa16d319adbd228fc152f5b9da730 (patch) | |
tree | 61d2c5e0e5839bae8731f067d429ac951687c29e /libc/misc/time | |
parent | 94889eacb194f5a61a99e296acbd1685788242d9 (diff) |
Fix ctime() standard compliance bug
fixes issue2209:
ctime() was updated in 0.9.31 to call localtime_r() instead of
localtime() to
avoid using a static buffer. Unfortunately, this change replaces the
static
buffer (which is zeroed out on initialization) with an uninitialized
local
buffer.
In the common case, this has no effect. However, with a sufficiently
large
time_t value, the value returned differs from that returned by
asctime(localtime(t)), and thus violates the ANSI/ISO standard.
An example input is (on a 64-bit machine):
time_t t = 0x7ffffffffff6c600;
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Diffstat (limited to 'libc/misc/time')
-rw-r--r-- | libc/misc/time/time.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/libc/misc/time/time.c b/libc/misc/time/time.c index 758a737fd..ff44892a8 100644 --- a/libc/misc/time/time.c +++ b/libc/misc/time/time.c @@ -479,6 +479,7 @@ char *ctime(const time_t *t) * localtime's static buffer: */ struct tm xtm; + memset(&xtm, 0, sizeof(xtm)); return asctime(localtime_r(t, &xtm)); } |