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)
{
DT_NONE = 0,
DT_BOOL,
DT_NUM,
+ DT_LNUM,
DT_STR,
DT_PATH,
DT_QUAD,
{ "DT_NONE", "-none-" },
{ "DT_BOOL", "boolean" },
{ "DT_NUM", "number" },
+ { "DT_LNUM", "number (long)" },
{ "DT_STR", "string" },
{ "DT_PATH", "path" },
{ "DT_QUAD", "quadoption" },
</listitem>
</varlistentry>
<varlistentry>
+<term>number (long)</term>
+<listitem>
+<para>
+A signed integer number in the range -2147483648 to 2147483647.
+</para>
+</listitem>
+</varlistentry>
+<varlistentry>
<term>string</term>
<listitem>
<para>
WHERE REGEXP PgpDecryptionOkay;
WHERE char *PgpDefaultKey;
WHERE char *PgpSignAs;
-WHERE short PgpTimeout;
+WHERE long PgpTimeout;
WHERE char *PgpEntryFormat;
WHERE char *PgpClearSignCommand;
WHERE char *PgpDecodeCommand;
/*-- formerly in smime.h --*/
WHERE char *SmimeDefaultKey;
WHERE char *SmimeSignAs;
-WHERE short SmimeTimeout;
+WHERE long SmimeTimeout;
WHERE char *SmimeCertificates;
WHERE char *SmimeKeys;
WHERE char *SmimeCryptAlg;
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;
*ptr = 0;
}
#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)
{
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;
#ifndef _MAKEDOC
#define DT_MASK 0x0f
#define DT_BOOL 1 /* boolean option */
-#define DT_NUM 2 /* a number */
+#define DT_NUM 2 /* a number (short) */
#define DT_STR 3 /* a string */
#define DT_PATH 4 /* a pathname */
#define DT_QUAD 5 /* quad-option (yes/no/ask-yes/ask-no) */
#define DT_SYN 9 /* synonym for another variable */
#define DT_ADDR 10 /* e-mail address */
#define DT_MBCHARTBL 11 /* multibyte char table */
+#define DT_LNUM 12 /* a number (long) */
#define DTYPE(x) ((x) & DT_MASK)
** this if you know what you are doing.
** (PGP only)
*/
- { "pgp_timeout", DT_NUM, R_NONE, UL &PgpTimeout, 300 },
+ { "pgp_timeout", DT_LNUM, R_NONE, UL &PgpTimeout, 300 },
/*
** .pp
** The number of seconds after which a cached passphrase will expire if
** possible \fCprintf(3)\fP-like sequences.
** (S/MIME only)
*/
- { "smime_timeout", DT_NUM, R_NONE, UL &SmimeTimeout, 300 },
+ { "smime_timeout", DT_LNUM, R_NONE, UL &SmimeTimeout, 300 },
/*
** .pp
** The number of seconds after which a cached passphrase will expire if
if (mutt_get_password (_("Enter PGP passphrase:"), PgpPass, sizeof (PgpPass)) == 0)
{
- PgpExptime = time (NULL) + PgpTimeout;
+ PgpExptime = mutt_add_timeout (time (NULL), PgpTimeout);
return (1);
}
else
time_t mutt_local_tz (time_t);
time_t mutt_mktime (struct tm *, int);
time_t mutt_parse_date (const char *, HEADER *);
+time_t mutt_add_timeout (time_t, long);
int is_from (const char *, char *, size_t, time_t *);
void mutt_touch_atime (int);
int mutt_timespec_compare (struct timespec *a, struct timespec *b);
if (mutt_get_password (_("Enter S/MIME passphrase:"), SmimePass, sizeof (SmimePass)) == 0)
{
- SmimeExptime = time (NULL) + SmimeTimeout;
+ SmimeExptime = mutt_add_timeout (time (NULL), SmimeTimeout);
return (1);
}
else