#3878: mtime to -1 for about 1% of the mails -------------------------+------------------------- Reporter: uxmutt | Owner: mutt-dev Type: defect | Status: reopened Priority: major | Milestone: Component: maildir/mh | Version: Resolution: | Keywords: utime mtime -------------------------+------------------------- Changes (by code@…):
* status: closed => reopened * resolution: fixed => Comment: {{{ On Sun, Sep 25, 2016 at 05:34:59PM -0000, Mutt wrote: Please do note that -1 is a perfectly valid, if unlikely, time_t. It corresponds to 23:59:59 Dec 31, 1969. That date really did happen, as my parents will attest. ;-) (I was not to be born for a few months yet, so...) A date of 0 is also perfectly valid. If you can do basic arithmetic I bet you'll be able to guess what date that corresponds to. So, if you want to make sure this will never have sloppy/wrong answers, mutt_parse_date() should probably be modified to have something like the following prototype: /* returns 0 (false) if parse fails, 1 (true) if succeeds */ int mutt_parse_date(const char *a, Header *b, time_t *c); And then it should set *c = the parsed time, if and only if it succeeds. But you also need a way to indicate whether hdr->received contains a valid time. One way to do that is to make it a pointer to a dynamic time_t, where NULL indicates it is not valid. If you want to avoid the dynamic allocation, you'll need a flag. Granted, it's unlikely most users will have e-mails dating from approximately New Years 1970, since e-mail wasn't invented until 1971, but... =8^) }}} -- Ticket URL: <https://dev.mutt.org/trac/ticket/3878#comment:5> Mutt <http://www.mutt.org/> The Mutt mail user agent