[tz] Invalid tm handling in %s pattern in strftime

Almaz Mingaleev mingaleev at google.com
Mon Jun 6 17:35:27 UTC 2022


Hi Paul,
https://github.com/eggert/tz/commit/8b238ec54c09556eb2aa405c1741eedfd12c4a87#diff-a001603e7d3e105c7c6d83ce1e92e6ed69e835e9698e39d78d338a9eb2cc1cfe
added
validation of tm argument.
I wonder why localtime_r call is done:
1) According to the man page mktime sets errno if tm is invalid. Why is it
not safe to just check errno value (saving and restoring it if needed)?
2) man page says that in error case mktime "returns (time_t) -1 and does
not alter the members of the broken-down time structure". Wouldn't it be
enough to check that tm.tm_yday is >= 0?

Thanks,
Almaz
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mm.icann.org/pipermail/tz/attachments/20220606/5d033d12/attachment.html>


More information about the tz mailing list