[Bug 192016] New: Incorrect result for %s in strftime

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Mon Jul 21 16:20:12 UTC 2014


            Bug ID: 192016
           Summary: Incorrect result for %s in strftime
           Product: Base System
           Version: 10.0-STABLE
          Hardware: Any
                OS: Any
            Status: Needs Triage
          Severity: Affects Many People
          Priority: ---
         Component: bin
          Assignee: freebsd-bugs at FreeBSD.org
          Reporter: quae at daurnimator.com

The %s specifier in strftime doesn't respect timezones.


    #include <time.h>
    #include <stdio.h>

    int main() {
        time_t t = 1234567890;
        struct tm *tmp = gmtime(&t);
        char output[200];
        strftime(output, 200, "%s", tmp);
        return 0;

Run with a non UTC timezone. e.g. TZ=GMT+9
Output will be 1234600290 instead of expected 1234567890

Location in BSD's libc:

This bug also exists in glibc:
Bug filed at https://sourceware.org/bugzilla/show_bug.cgi?id=17189

It does not occur in musl:

You are receiving this mail because:
You are the assignee for the bug.

More information about the freebsd-bugs mailing list