Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMquMNTmDZnGvtPo3H0Uo-3ytGDO5EHa+RHCBTZTph6c3WFsYA@mail.gmail.com>
Date: Mon, 15 Mar 2021 21:43:36 +0200
From: Yossi Gottlieb <yossigo@...il.com>
To: musl@...ts.openwall.com
Subject: strftime() unexpectedly modifies errno

It seems like strftime() unexpectedly modifies errno, which is always set
to EINVAL when it returns. Looks like it's not related to any specific
format.

Here's an example:

#include <stdio.h>
#include <sys/time.h>
#include <time.h>
#include <errno.h>

int main(int argc, char *argv[])
{
    time_t now = time(NULL);
    struct tm *tm = localtime(&now);
    char buf[100];

    errno = 0;
    size_t len = strftime(buf, sizeof(buf), "%d %b %Y %H:%M:%S.", tm);

    printf("len=%zu\n", len);
    printf("buf=%s\n", buf);
    printf("errno=%d\n", errno);
}

Content of type "text/html" skipped

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.