Commit 2a857f63 authored by Kevin J. McCarthy's avatar Kevin J. McCarthy

Fix is_from() year parsing to abort on year overflow.

Unlike mutt_parse_date(), is_from() was not checking for overflow, and
could end up passing a negative year to mutt_mktime().

It should perhaps be changed to use mutt_atoi(), which does better
range checking, but that requires mutt_atoi() being changed to allow
trailing characters and its callers return value checks being
updated.  I'll put that on the todo list.
parent 189e52d5
......@@ -185,7 +185,7 @@ int is_from (const char *s, char *path, size_t pathlen, time_t *tp)
/* year */
if (sscanf (s, "%d", &yr) != 1) return 0;
if (sscanf (s, "%d", &yr) != 1 || yr < 0) return 0;
tm.tm_year = yr > 1900 ? yr - 1900 : (yr < 70 ? yr + 100 : yr);
dprint (3,(debugfile, "is_from(): month=%d, day=%d, hr=%d, min=%d, sec=%d, yr=%d.\n",
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment