#3990: segfault in hdr_format_str --------------------------+---------------------- Reporter: josephbisch | Owner: mutt-dev Type: defect | Status: new Priority: major | Milestone: Component: mutt | Version: Resolution: | Keywords: --------------------------+----------------------
Comment (by vinc17): The bug is in Mutt: it doesn't check whether {{{localtime}}} or {{{gmtime}}} succeeds. POSIX says: "If an error is detected, gmtime() shall return a null pointer". But Mutt passes {{{tm}}} to {{{strftime}}} without checking whether it is a null pointer. So there are two issues. 1. Check whether {{{tm}}} is a null pointer. I don't know what should be done in such a case. If the second issue is solved, this should never happen. Perhaps exit with an error message giving information about the time that lead to this error. 2. Make sure that the time is always representable in a {{{tm}}} structure. The maximum year for the {{{tm}}} structure is mathematically 1900 + {{{INT_MAX}}}. But for simplicity, {{{INT_MAX}}} would also be OK (thus the year could always be represented in an {{{int}}} if need be, even without the 1900 offset). Capping the value to 9999 would be OK too, I assume, with the advantage that the year would always be representable on 4 digits, thus avoiding potential display issues. -- Ticket URL: <https://dev.mutt.org/trac/ticket/3990#comment:4> Mutt <http://www.mutt.org/> The Mutt mail user agent