return 0;
if (sscanf(s, "%d", &tm.tm_mday) != 1)
return 0;
+ if ((tm.tm_mday < 1) || (tm.tm_mday > 31))
+ return 0;
/* time */
s = next_word(s);
else
return 0;
+ if ((tm.tm_hour < 0) || (tm.tm_hour > 23) || (tm.tm_min < 0) ||
+ (tm.tm_min > 59) || (tm.tm_sec < 0) || (tm.tm_sec > 60))
+ return 0;
+
s = next_word(s);
if (!*s)
return 0;
/* year */
if (sscanf(s, "%d", &yr) != 1)
return 0;
+ if ((yr < 0) || (yr > 9999))
+ return 0;
tm.tm_year = yr > 1900 ? yr - 1900 : (yr < 70 ? yr + 100 : yr);
mutt_debug(3, "is_from(): month=%d, day=%d, hr=%d, min=%d, sec=%d, yr=%d.\n",
if ((time_t) t->tm_year < (TM_YEAR_MIN - 1900))
return TIME_T_MIN;
+ if ((t->tm_mday < 1) || (t->tm_mday > 31))
+ return TIME_T_MIN;
+ if ((t->tm_hour < 0) || (t->tm_hour > 23) || (t->tm_min < 0) ||
+ (t->tm_min > 59) || (t->tm_sec < 0) || (t->tm_sec > 60))
+ return TIME_T_MIN;
+ if (t->tm_year > 9999)
+ return TIME_T_MAX;
+
/* Compute the number of days since January 1 in the same year */
g = AccumDaysPerMonth[t->tm_mon % 12];
case 1: /* month of the year */
i = mutt_check_month(t);
- if (i < 0)
+ if ((i < 0) || (i > 11))
return -1;
tm.tm_mon = i;
break;
case 2: /* year */
if ((mutt_atoi(t, &tm.tm_year) < 0) || (tm.tm_year < 0))
return -1;
+ if ((tm.tm_year < 0) || (tm.tm_year > 9999))
+ return -1;
if (tm.tm_year < 50)
tm.tm_year += 100;
else if (tm.tm_year >= 1900)
mutt_debug(1, "parse_date: could not process time format: %s\n", t);
return -1;
}
+ if ((hour < 0) || (hour > 23) || (min < 0) ||
+ (min > 59) || (sec < 0) || (sec > 60))
+ return -1;
tm.tm_hour = hour;
tm.tm_min = min;
tm.tm_sec = sec;