Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date: Mon, 10 Aug 2020 15:31:23 +0200
From: Nikita Popov <nikita.ppv@...il.com>
To: musl@...ts.openwall.com
Subject: strftime %Z behavior with manually populated struct tm

Hi,

Currently, strftime() %Z will print an empty string if the provided tm_zone
does not originate from musl. It appears that this behavior is explicitly
implemented in __tm_to_tzname(). Would it be possible to instead print any
non-NULL tm_zone as provided?

For consumers manually populating the struct tm structure, it is
non-trivial to work around the current behavior. Python introduced a work
around in
https://github.com/python/cpython/commit/163eca34c48f1b25e1504e37f4656773fd0fdc78,
but it is not easy to generalize.

>From what I gathered, the original concern here was that a consumer
manually initializing struct tm may not initialize the tm_zone field. As
struct tm is only specified to contain "at least" certain members, manual
initialization of this structure is already on shaky ground anyway and I
think it is more useful to assume the initialization is correct than try to
deal with garbage data. Because other libc implementation do not try to
validate the pointer either (beyond being non-NULL), incorrect
initialization is unlikely in practice.

Regards,
Nikita

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.