[Bug 2209] New: ctime(*t) can return garbage with large t

bugzilla at busybox.net bugzilla at busybox.net
Mon Jul 12 07:04:53 UTC 2010


https://bugs.busybox.net/show_bug.cgi?id=2209

           Summary: ctime(*t) can return garbage with large t
           Product: uClibc
           Version: 0.9.31
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: minor
          Priority: P5
         Component: Standard Compliance
        AssignedTo: unassigned at uclibc.org
        ReportedBy: ramos at cs.stanford.edu
                CC: uclibc-cvs at uclibc.org
   Estimated Hours: 0.0


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;

When passed to uClibc 0.9.30.3, the resulting string is:
"Sun Jan  0 15:32:16 1900"

When passed to uClibc 0.9.31, the resulting string is:
"??? ??? ?? 15:32:16 ????"

The recommended fix is to zero-out the 'tm' struct using memset() before
calling localtime_r.

-- 
Configure bugmail: https://bugs.busybox.net/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


More information about the uClibc-cvs mailing list