On 32-bit arches it's easy to over-/under-flow the date.
We replace these with the max/min values allowed in a time_t.
When we encounter one of these dates, pretend it's UTC to prevent
another overflow.
Fixes #819
Fixes #820
*/
time_t mutt_local_tz(time_t t)
{
+ /* Check we haven't overflowed the time (on 32-bit arches) */
+ if ((t == TIME_T_MAX) || (t == TIME_T_MIN))
+ return 0;
+
struct tm *ptm = NULL;
struct tm utc;
tz_out->zoccident = zoccident;
}
- return (mutt_mktime(&tm, 0) + tz_offset);
+ time_t time = mutt_mktime(&tm, 0);
+ /* Check we haven't overflowed the time (on 32-bit arches) */
+ if ((time != TIME_T_MAX) && (time != TIME_T_MIN))
+ time += tz_offset;
+
+ return time;
}
/**