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 /init.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 'init.c')
-rw-r--r-- | init.c | 41 |
1 files changed, 41 insertions, 0 deletions
@@ -1766,6 +1766,9 @@ static void mutt_restore_default (struct option_t *p) case DT_MAGIC: *((short *) p->data) = p->init; break; + case DT_LNUM: + *((long *) p->data) = p->init; + break; case DT_RX: { REGEXP *pp = (REGEXP *) p->data; @@ -2493,6 +2496,38 @@ static int parse_set (BUFFER *tmp, BUFFER *s, unsigned long data, BUFFER *err) } #endif } + else if (DTYPE(MuttVars[idx].type) == DT_LNUM) + { + long *ptr = (long *) MuttVars[idx].data; + long val; + int rc; + + if (query || *s->dptr != '=') + { + val = *ptr; + + /* user requested the value of this variable */ + snprintf (err->data, err->dsize, "%s=%ld", MuttVars[idx].option, val); + break; + } + + CHECK_PAGER; + s->dptr++; + + mutt_extract_token (tmp, s, 0); + rc = mutt_atol (tmp->data, (long *) &val); + + if (rc < 0 || !*tmp->data) + { + snprintf (err->data, err->dsize, _("%s: invalid value (%s)"), tmp->data, + rc == -1 ? _("format error") : _("number overflow")); + r = -1; + break; + } + else + *ptr = val; + + } else if (DTYPE (MuttVars[idx].type) == DT_QUAD) { if (query) @@ -3065,6 +3100,12 @@ static int var_to_string (int idx, char* val, size_t len) snprintf (tmp, sizeof (tmp), "%d", sval); } + else if (DTYPE (MuttVars[idx].type) == DT_LNUM) + { + long sval = *((long *) MuttVars[idx].data); + + snprintf (tmp, sizeof (tmp), "%ld", sval); + } else if (DTYPE (MuttVars[idx].type) == DT_SORT) { const struct mapping_t *map; |