Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date: Sat, 23 Jul 2022 02:09:25 +0000
From: John Scott <>
Subject: Feature request: strftime() should set errno on failure


My apologies, I don't have a patch, but I think strftime() should set
errno on failure as POSIX Issue 8 stipulates:
I think this functionality is valuable enough that I'd really love it to
be implemented soon, even if it doesn't make it into the final standard
for whatever reason.

Right now, when one gets a return value of 0, there is no way to
distinguish the buffer being too small from other causes of error, which
means there's no way to tell whether a caller should try reallocating
with a larger buffer. Since strftime() is not snprintf-like (but perhaps
it could be as an extension since passing NULL to strftime is undefined,
not that I'm actually recommending that), there's no way to know how big
of a buffer is big enough. Indeed, it's not even clear if NL_TEXTMAX
applies here.

Setting errno to ERANGE would let the caller know whether a larger
buffer should be tried or if the effort will fruitlessly allocate large
amounts of memory.

Thank you.

Download attachment "signature.asc" of type "application/pgp-signature" (253 bytes)

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.