diff options
author | Eike Rathke <erack@erack.de> | 2018-06-18 22:04:47 +0200 |
---|---|---|
committer | Eike Rathke <erack@erack.de> | 2018-06-18 22:04:47 +0200 |
commit | 4bc76c2f3d425a95b30b06cc73cb7c73f34f26db (patch) | |
tree | 3beb1740ec413eb36ceab7ace6511545c26d3f47 /date.c | |
parent | 508ff2377e1394b2c3dc63602da3e81a4d0cdb52 (diff) |
Allow larger passphrase timeout values
This came up in the comp.mail.mutt newsgroup where a user wasn't
satisfied with the SHORT_MAX seconds ~9 hours limit on passphrase
timeouts.
For the first time made it necessary for the options parser to be
able to parse numbers as long values. Also, introduced
mutt_add_timeout() to detect possible overflow before adding a
timeout to a time_t value and truncate to TIME_T_MAX instead.
Diffstat (limited to 'date.c')
-rw-r--r-- | date.c | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -120,6 +120,19 @@ time_t mutt_mktime (struct tm *t, int local) return (g); } +/* Safely add a timeout to a given time_t value, truncating instead of + * overflowing. */ +time_t mutt_add_timeout (time_t now, long timeout) +{ + if (timeout < 0) + return now; + + if (TIME_T_MAX - now < timeout) + return TIME_T_MAX; + + return now + timeout; +} + /* Return 1 if month is February of leap year, else 0 */ static int isLeapYearFeb (struct tm *tm) { |