This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libc/17189] New: Incorrect result for %s in strftime


https://sourceware.org/bugzilla/show_bug.cgi?id=17189

            Bug ID: 17189
           Summary: Incorrect result for %s in strftime
           Product: glibc
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
          Assignee: unassigned at sourceware dot org
          Reporter: quae at daurnimator dot com
                CC: drepper.fsp at gmail dot com

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

Example:

    #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);
        printf("%s\n",output);
        return 0;
    }

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


Location in glibc:
http://fossies.org/dox/glibc-2.19/strftime__l_8c_source.html#l01133

This bug also exists in BSD's libc:
https://svnweb.freebsd.org/base/release/10.0.0/lib/libc/stdtime/strftime.c?view=markup#l312

It does not occur in musl:
http://git.musl-libc.org/cgit/musl/tree/src/time/strftime.c?id=ac0acd569e01735fc6052d43fdf57f3a07c93f3d#n127

-- 
You are receiving this mail because:
You are on the CC list for the bug.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]