summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin McCarthy <kevin@8t8.us>2021-01-26 12:58:54 -0800
committerKevin McCarthy <kevin@8t8.us>2021-01-27 13:54:38 -0800
commit5d73e4cf196abcfe2ef2a39ce2233ac080156cdb (patch)
tree74f8a8bec78f73efd66c6b4b041e5f0569ca63b7
parent7737b353357f6d8d6a86d5822d4afb98c4e444ef (diff)
Convert all mutt_atoX functions to behave strictly.
* Remove the automatic conversion of NULL and '\0' to 0. Add a flag for the cases that require lax evaluation. * Make trailing characters generate an error by default for the mutt_atouX functions. Add a flag for that case. Most of the IMAP code parses numbers out of a stream, so add the flag to those calls. * The mutt_atouX functions were also behaving incorrectly with invalid input, e.g. "ABC", returning and setting 0. Fix them to return an error in those cases. * Add a mutt_atoll() function, to be used in the next commit. * Change converters to store 0 on error. atos, atoi, and atoui were already doing this, but the others were not.
-rw-r--r--curs_main.c2
-rw-r--r--edit.c2
-rw-r--r--gnupgparse.c12
-rw-r--r--imap/command.c11
-rw-r--r--imap/imap.c6
-rw-r--r--imap/message.c10
-rw-r--r--imap/util.c6
-rw-r--r--init.c10
-rw-r--r--lib.c179
-rw-r--r--lib.h24
-rw-r--r--main.c2
-rw-r--r--menu.c2
-rw-r--r--mh.c8
-rw-r--r--parse.c9
-rw-r--r--resize.c4
-rw-r--r--rfc2231.c2
-rw-r--r--score.c2
-rw-r--r--smtp.c2
-rw-r--r--url.c2
19 files changed, 180 insertions, 115 deletions
diff --git a/curs_main.c b/curs_main.c
index 8ab9173a..1b7f121c 100644
--- a/curs_main.c
+++ b/curs_main.c
@@ -931,7 +931,7 @@ int mutt_index_menu (void)
break;
}
- if (mutt_atoi (buf, &i) < 0)
+ if (mutt_atoi (buf, &i, 0) < 0)
{
mutt_error _("Argument must be a message number.");
break;
diff --git a/edit.c b/edit.c
index 8bb8b636..33d33e27 100644
--- a/edit.c
+++ b/edit.c
@@ -156,7 +156,7 @@ be_include_messages (char *msg, char **buf, int *bufmax, int *buflen,
while ((msg = strtok (msg, " ,")) != NULL)
{
- if (mutt_atoi (msg, &n) == 0 && n > 0 && n <= Context->msgcount)
+ if (mutt_atoi (msg, &n, 0) == 0 && n > 0 && n <= Context->msgcount)
{
n--;
diff --git a/gnupgparse.c b/gnupgparse.c
index 7142288e..9df7d502 100644
--- a/gnupgparse.c
+++ b/gnupgparse.c
@@ -217,7 +217,7 @@ static pgp_key_t parse_pub_line (char *buf, int *is_subkey, pgp_key_t k)
dprint (2, (debugfile, "key len: %s\n", p));
if (!(*is_subkey && option (OPTPGPIGNORESUB)) &&
- mutt_atos (p, &tmp.keylen) < 0)
+ mutt_atos (p, &tmp.keylen, MUTT_ATOI_ALLOW_EMPTY) < 0)
goto bail;
break;
}
@@ -228,7 +228,7 @@ static pgp_key_t parse_pub_line (char *buf, int *is_subkey, pgp_key_t k)
if (!(*is_subkey && option (OPTPGPIGNORESUB)))
{
int x = 0;
- if (mutt_atoi (p, &x) < 0)
+ if (mutt_atoi (p, &x, MUTT_ATOI_ALLOW_EMPTY) < 0)
goto bail;
tmp.numalg = x;
tmp.algorithm = pgp_pkalgbytype (x);
@@ -259,19 +259,19 @@ static pgp_key_t parse_pub_line (char *buf, int *is_subkey, pgp_key_t k)
strncpy (tstr, p, 11);
tstr[4] = '\0';
tstr[7] = '\0';
- if (mutt_atoi (tstr, &time.tm_year) < 0)
+ if (mutt_atoi (tstr, &time.tm_year, 0) < 0)
{
p = tstr;
goto bail;
}
time.tm_year -= 1900;
- if (mutt_atoi (tstr+5, &time.tm_mon) < 0)
+ if (mutt_atoi (tstr+5, &time.tm_mon, 0) < 0)
{
p = tstr+5;
goto bail;
}
time.tm_mon -= 1;
- if (mutt_atoi (tstr+8, &time.tm_mday) < 0)
+ if (mutt_atoi (tstr+8, &time.tm_mday, 0) < 0)
{
p = tstr+8;
goto bail;
@@ -282,7 +282,7 @@ static pgp_key_t parse_pub_line (char *buf, int *is_subkey, pgp_key_t k)
{
unsigned long long secs;
- if (mutt_atoull (p, &secs) < 0)
+ if (mutt_atoull (p, &secs, MUTT_ATOI_ALLOW_EMPTY) < 0)
goto bail;
tmp.gen_time = (time_t)secs;
}
diff --git a/imap/command.c b/imap/command.c
index d9450852..340d5bb9 100644
--- a/imap/command.c
+++ b/imap/command.c
@@ -534,7 +534,8 @@ static int cmd_handle_untagged (IMAP_DATA* idata)
dprint (2, (debugfile, "Handling EXISTS\n"));
/* new mail arrived */
- mutt_atoui (pn, &count);
+ if (mutt_atoui (pn, &count, MUTT_ATOI_ALLOW_TRAILING) < 0)
+ return 0;
if (count < idata->max_msn)
{
@@ -651,7 +652,7 @@ static void cmd_parse_expunge (IMAP_DATA* idata, const char* s)
dprint (2, (debugfile, "Handling EXPUNGE\n"));
- if (mutt_atoui (s, &exp_msn) < 0 ||
+ if (mutt_atoui (s, &exp_msn, MUTT_ATOI_ALLOW_TRAILING) < 0 ||
exp_msn < 1 || exp_msn > idata->max_msn)
return;
@@ -784,7 +785,7 @@ static void cmd_parse_fetch (IMAP_DATA* idata, char* s)
dprint (3, (debugfile, "Handling FETCH\n"));
- if (mutt_atoui (s, &msn) < 0)
+ if (mutt_atoui (s, &msn, MUTT_ATOI_ALLOW_TRAILING) < 0)
{
dprint (3, (debugfile, "cmd_parse_fetch: Skipping FETCH response - illegal MSN\n"));
return;
@@ -853,7 +854,7 @@ static void cmd_parse_fetch (IMAP_DATA* idata, char* s)
{
s += 3;
SKIPWS (s);
- if (mutt_atoui (s, &uid) < 0)
+ if (mutt_atoui (s, &uid, MUTT_ATOI_ALLOW_TRAILING) < 0)
{
dprint (1, (debugfile, "cmd_parse_fetch: Illegal UID. Skipping update.\n"));
return;
@@ -1116,7 +1117,7 @@ static void cmd_parse_search (IMAP_DATA* idata, const char* s)
while ((s = imap_next_word ((char*)s)) && *s != '\0')
{
- if (mutt_atoui (s, &uid) < 0)
+ if (mutt_atoui (s, &uid, MUTT_ATOI_ALLOW_TRAILING) < 0)
continue;
h = (HEADER *)int_hash_find (idata->uid_hash, uid);
if (h)
diff --git a/imap/imap.c b/imap/imap.c
index 2376abb7..9147f1ee 100644
--- a/imap/imap.c
+++ b/imap/imap.c
@@ -900,7 +900,7 @@ static int imap_open_mailbox (CONTEXT* ctx)
dprint (3, (debugfile, "Getting mailbox UIDVALIDITY\n"));
pc += 3;
pc = imap_next_word (pc);
- if (mutt_atoui (pc, &idata->uid_validity) < 0)
+ if (mutt_atoui (pc, &idata->uid_validity, MUTT_ATOI_ALLOW_TRAILING) < 0)
goto fail;
status->uidvalidity = idata->uid_validity;
}
@@ -909,7 +909,7 @@ static int imap_open_mailbox (CONTEXT* ctx)
dprint (3, (debugfile, "Getting mailbox UIDNEXT\n"));
pc += 3;
pc = imap_next_word (pc);
- if (mutt_atoui (pc, &idata->uidnext) < 0)
+ if (mutt_atoui (pc, &idata->uidnext, MUTT_ATOI_ALLOW_TRAILING) < 0)
goto fail;
status->uidnext = idata->uidnext;
}
@@ -918,7 +918,7 @@ static int imap_open_mailbox (CONTEXT* ctx)
dprint (3, (debugfile, "Getting mailbox HIGHESTMODSEQ\n"));
pc += 3;
pc = imap_next_word (pc);
- if (mutt_atoull (pc, &idata->modseq) < 0)
+ if (mutt_atoull (pc, &idata->modseq, MUTT_ATOI_ALLOW_TRAILING) < 0)
goto fail;
status->modseq = idata->modseq;
}
diff --git a/imap/message.c b/imap/message.c
index 48853b4f..4c859921 100644
--- a/imap/message.c
+++ b/imap/message.c
@@ -682,7 +682,7 @@ static int read_headers_condstore_qresync_updates (IMAP_DATA *idata,
fetch_buf = imap_next_word (fetch_buf);
if (!isdigit ((unsigned char) *fetch_buf) ||
- mutt_atoui (fetch_buf, &header_msn) < 0)
+ mutt_atoui (fetch_buf, &header_msn, MUTT_ATOI_ALLOW_TRAILING) < 0)
continue;
if (header_msn < 1 || header_msn > msn_end ||
@@ -1139,7 +1139,7 @@ int imap_fetch_message (CONTEXT *ctx, MESSAGE *msg, int msgno, int headers)
if (ascii_strncasecmp ("UID", pc, 3) == 0)
{
pc = imap_next_word (pc);
- if (mutt_atoui (pc, &uid) < 0)
+ if (mutt_atoui (pc, &uid, MUTT_ATOI_ALLOW_TRAILING) < 0)
goto bail;
if (uid != HEADER_DATA(h)->uid)
mutt_error (_("The message index is incorrect. Try reopening the mailbox."));
@@ -1825,7 +1825,7 @@ static int msg_fetch_header (CONTEXT* ctx, IMAP_HEADER* h, char* buf, FILE* fp)
/* skip to message number */
buf = imap_next_word (buf);
- if (mutt_atoui (buf, &h->data->msn) < 0)
+ if (mutt_atoui (buf, &h->data->msn, MUTT_ATOI_ALLOW_TRAILING) < 0)
return rc;
/* find FETCH tag */
@@ -1899,7 +1899,7 @@ static int msg_parse_fetch (IMAP_HEADER *h, char *s)
{
s += 3;
SKIPWS (s);
- if (mutt_atoui (s, &h->data->uid) < 0)
+ if (mutt_atoui (s, &h->data->uid, MUTT_ATOI_ALLOW_TRAILING) < 0)
return -1;
s = imap_next_word (s);
@@ -1939,7 +1939,7 @@ static int msg_parse_fetch (IMAP_HEADER *h, char *s)
dlen--;
}
*ptmp = 0;
- if (mutt_atol (tmp, &h->content_length) < 0)
+ if (mutt_atol (tmp, &h->content_length, 0) < 0)
return -1;
}
else if (!ascii_strncasecmp ("BODY", s, 4) ||
diff --git a/imap/util.c b/imap/util.c
index c529fd8f..6400dd68 100644
--- a/imap/util.c
+++ b/imap/util.c
@@ -597,7 +597,7 @@ int imap_get_literal_count(const char *buf, unsigned int *bytes)
while (isdigit ((unsigned char) *pc))
pc++;
*pc = 0;
- if (mutt_atoui (pn, bytes) < 0)
+ if (mutt_atoui (pn, bytes, 0) < 0)
return -1;
return 0;
@@ -1048,11 +1048,11 @@ int mutt_seqset_iterator_next (SEQSET_ITERATOR *iter, unsigned int *next)
if (range_sep)
*range_sep++ = '\0';
- if (mutt_atoui (iter->substr_cur, &iter->range_cur))
+ if (mutt_atoui (iter->substr_cur, &iter->range_cur, 0))
return -1;
if (range_sep)
{
- if (mutt_atoui (range_sep, &iter->range_end))
+ if (mutt_atoui (range_sep, &iter->range_end, 0))
return -1;
}
else
diff --git a/init.c b/init.c
index 151a0614..63cbdbda 100644
--- a/init.c
+++ b/init.c
@@ -2607,9 +2607,8 @@ static int parse_set (BUFFER *tmp, BUFFER *s, union pointer_long_t udata, BUFFER
s->dptr++;
mutt_extract_token (tmp, s, 0);
- rc = mutt_atos (tmp->data, (short *) &val);
-
- if (rc < 0 || !*tmp->data)
+ rc = mutt_atos (tmp->data, (short *) &val, 0);
+ if (rc < 0)
{
snprintf (err->data, err->dsize, _("%s: invalid value (%s)"), tmp->data,
rc == -1 ? _("format error") : _("number overflow"));
@@ -2671,9 +2670,8 @@ static int parse_set (BUFFER *tmp, BUFFER *s, union pointer_long_t udata, BUFFER
s->dptr++;
mutt_extract_token (tmp, s, 0);
- rc = mutt_atol (tmp->data, (long *) &val);
-
- if (rc < 0 || !*tmp->data)
+ rc = mutt_atol (tmp->data, (long *) &val, 0);
+ if (rc < 0)
{
snprintf (err->data, err->dsize, _("%s: invalid value (%s)"), tmp->data,
rc == -1 ? _("format error") : _("number overflow"));
diff --git a/lib.c b/lib.c
index 3c38f12b..f77707a7 100644
--- a/lib.c
+++ b/lib.c
@@ -829,7 +829,28 @@ void mutt_debug_f (const char *file, const int line, const char *function, const
#endif /* DEBUG */
-int mutt_atos (const char *str, short *dst)
+
+/**********************************************************************
+ * mutt_atoX functions
+ *
+ * By default these all operate in a "strict mode", returning:
+ *
+ * * -1 if input is NULL or "".
+ * Pass flag MUTT_ATOI_ALLOW_EMPTY to return 0 in that case.
+ *
+ * * -1 if there is trailing input after the number.
+ * Pass flag MUTT_ATOI_ALLOW_TRAILING to return 0 in that case.
+ *
+ * * -2 if the number is out of range
+ *
+ * Note that the dst parameter will be set to 0 on error.
+ *********************************************************************/
+
+/* returns: 0 - successful conversion
+ * -1 - error: invalid input
+ * -2 - error: out of range
+ */
+int mutt_atos (const char *str, short *dst, int flags)
{
int rc;
long res;
@@ -838,16 +859,20 @@ int mutt_atos (const char *str, short *dst)
*t = 0;
- if ((rc = mutt_atol (str, &res)) < 0)
+ if ((rc = mutt_atol (str, &res, flags)) < 0)
return rc;
if ((short) res != res)
return -2;
*t = (short) res;
- return 0;
+ return rc;
}
-int mutt_atoi (const char *str, int *dst)
+/* returns: 0 - successful conversion
+ * -1 - error: invalid input
+ * -2 - error: out of range
+ */
+int mutt_atoi (const char *str, int *dst, int flags)
{
int rc;
long res;
@@ -856,48 +881,78 @@ int mutt_atoi (const char *str, int *dst)
*t = 0;
- if ((rc = mutt_atol (str, &res)) < 0)
+ if ((rc = mutt_atol (str, &res, flags)) < 0)
return rc;
if ((int) res != res)
return -2;
*t = (int) res;
- return 0;
+ return rc;
}
-int mutt_atol (const char *str, long *dst)
+/* returns: 0 - successful conversion
+ * -1 - error: invalid input
+ * -2 - error: out of range
+ */
+int mutt_atol (const char *str, long *dst, int flags)
{
- long r;
- long *res = dst ? dst : &r;
+ long tmp, res;
+ long *t = dst ? dst : &tmp;
char *e = NULL;
- /* no input: 0 */
+ *t = 0;
+
if (!str || !*str)
- {
- *res = 0;
- return 0;
- }
+ return (flags & MUTT_ATOI_ALLOW_EMPTY) ? 0 : -1;
errno = 0;
- *res = strtol (str, &e, 10);
- if (e && *e != '\0')
+ res = strtol (str, &e, 10);
+
+ if (errno == ERANGE)
+ return -2;
+ if (e == str)
return -1;
+ if ((*e != '\0') && !(flags & MUTT_ATOI_ALLOW_TRAILING))
+ return -1;
+
+ *t = res;
+ return 0;
+}
+
+/* returns: 0 - successful conversion
+ * -1 - error: invalid input
+ * -2 - error: out of range
+ */
+int mutt_atoll (const char *str, long long *dst, int flags)
+{
+ long long tmp, res;
+ long long *t = dst ? dst : &tmp;
+ char *e = NULL;
+
+ *t = 0;
+
+ if (!str || !*str)
+ return (flags & MUTT_ATOI_ALLOW_EMPTY) ? 0 : -1;
+
+ errno = 0;
+ res = strtoll (str, &e, 10);
+
if (errno == ERANGE)
return -2;
+ if (e == str)
+ return -1;
+ if ((*e != '\0') && !(flags & MUTT_ATOI_ALLOW_TRAILING))
+ return -1;
+
+ *t = res;
return 0;
}
-/* NOTE: this function's return value breaks with the above three functions.
- * The imap code lexes uint values out of a stream of characters without
- * tokenization. The above functions return -1 if there is input beyond
- * the number.
- *
- * returns: 1 - successful conversion, with trailing characters
- * 0 - successful conversion
- * -1 - invalid input
- * -2 - input out of range
+/* returns: 0 - successful conversion
+ * -1 - error: invalid input
+ * -2 - error: out of range
*/
-int mutt_atoui (const char *str, unsigned int *dst)
+int mutt_atoui (const char *str, unsigned int *dst, int flags)
{
int rc;
unsigned long res;
@@ -906,7 +961,7 @@ int mutt_atoui (const char *str, unsigned int *dst)
*t = 0;
- if ((rc = mutt_atoul (str, &res)) < 0)
+ if ((rc = mutt_atoul (str, &res, flags)) < 0)
return rc;
if ((unsigned int) res != res)
return -2;
@@ -915,58 +970,60 @@ int mutt_atoui (const char *str, unsigned int *dst)
return rc;
}
-/* NOTE: this function's return value is different from mutt_atol.
- *
- * returns: 1 - successful conversion, with trailing characters
- * 0 - successful conversion
- * -1 - invalid input
+/* returns: 0 - successful conversion
+ * -1 - error: invalid input
+ * -2 - error: out of range
*/
-int mutt_atoul (const char *str, unsigned long *dst)
+int mutt_atoul (const char *str, unsigned long *dst, int flags)
{
- unsigned long r;
- unsigned long *res = dst ? dst : &r;
+ unsigned long tmp, res;
+ unsigned long *t = dst ? dst : &tmp;
char *e = NULL;
- /* no input: 0 */
+ *t = 0;
+
if (!str || !*str)
- {
- *res = 0;
- return 0;
- }
+ return (flags & MUTT_ATOI_ALLOW_EMPTY) ? 0 : -1;
errno = 0;
- *res = strtoul (str, &e, 10);
- if (*res == ULONG_MAX && errno == ERANGE)
+ res = strtoul (str, &e, 10);
+
+ if (errno == ERANGE)
+ return -2;
+ if (e == str)
return -1;
- if (e && *e != '\0')
- return 1;
+ if ((*e != '\0') && !(flags & MUTT_ATOI_ALLOW_TRAILING))
+ return -1;
+
+ *t = res;
return 0;
}
-/* NOTE: this function's return value is different from mutt_atol.
- *
- * returns: 1 - successful conversion, with trailing characters
- * 0 - successful conversion
- * -1 - invalid input
+/* returns: 0 - successful conversion
+ * -1 - error: invalid input
+ * -2 - error: out of range
*/
-int mutt_atoull (const char *str, unsigned long long *dst)
+int mutt_atoull (const char *str, unsigned long long *dst, int flags)
{
- unsigned long long r;
- unsigned long long *res = dst ? dst : &r;
+ unsigned long long tmp, res;
+ unsigned long long *t = dst ? dst : &tmp;
char *e = NULL;
- /* no input: 0 */
+ *t = 0;
+
if (!str || !*str)
- {
- *res = 0;
- return 0;
- }
+ return (flags & MUTT_ATOI_ALLOW_EMPTY) ? 0 : -1;
errno = 0;
- *res = strtoull (str, &e, 10);
- if (*res == ULLONG_MAX && errno == ERANGE)
+ res = strtoull (str, &e, 10);
+
+ if (errno == ERANGE)
+ return -2;
+ if (e == str)
+ return -1;
+ if ((*e != '\0') && !(flags & MUTT_ATOI_ALLOW_TRAILING))
return -1;
- if (e && *e != '\0')
- return 1;
+
+ *t = res;
return 0;
}
diff --git a/lib.h b/lib.h
index 1e98692d..9ee281f6 100644
--- a/lib.h
+++ b/lib.h
@@ -184,18 +184,26 @@ char *safe_strcat (char *, size_t, const char *);
char *safe_strncat (char *, size_t, const char *, size_t);
char *safe_strdup (const char *);
+/* mutt_atoX() flags:
+ *
+ * Without the flag, the function will return -1, but the dst parameter
+ * will still be set to 0. */
+#define MUTT_ATOI_ALLOW_EMPTY (1<<0) /* allow NULL or "" */
+#define MUTT_ATOI_ALLOW_TRAILING (1<<1) /* allow values after the number */
+
/* strtol() wrappers with range checking; they return
* 0 success
* -1 format error
- * -2 overflow (for int and short)
- * the int pointer may be NULL to test only without conversion
+ * -2 out of range
+ * the dst pointer may be NULL to test only without conversion
*/
-int mutt_atos (const char *, short *);
-int mutt_atoi (const char *, int *);
-int mutt_atol (const char *, long *);
-int mutt_atoui (const char *, unsigned int *);
-int mutt_atoul (const char *, unsigned long *);
-int mutt_atoull (const char *, unsigned long long *);
+int mutt_atos (const char *, short *, int);
+int mutt_atoi (const char *, int *, int);
+int mutt_atol (const char *, long *, int);
+int mutt_atoll (const char *, long long *, int);
+int mutt_atoui (const char *, unsigned int *, int);
+int mutt_atoul (const char *, unsigned long *, int);
+int mutt_atoull (const char *, unsigned long long *, int);
const char *mutt_stristr (const char *, const char *);
const char *mutt_basename (const char *);
diff --git a/main.c b/main.c
index d813e885..7729150f 100644
--- a/main.c
+++ b/main.c
@@ -743,7 +743,7 @@ int main (int argc, char **argv, char **environ)
case 'd':
#ifdef DEBUG
- mutt_atoi (optarg, &debuglevel);
+ mutt_atoi (optarg, &debuglevel, 0);
printf (_("Debugging at level %d.\n"), debuglevel);
#else
printf ("%s", _("DEBUG was not defined during compilation. Ignored.\n"));
diff --git a/menu.c b/menu.c
index a7fff292..59c94a2c 100644
--- a/menu.c
+++ b/menu.c
@@ -464,7 +464,7 @@ void menu_jump (MUTTMENU *menu)
buf[0] = 0;
if (mutt_get_field (_("Jump to: "), buf, sizeof (buf), 0) == 0 && buf[0])
{
- if (mutt_atoi (buf, &n) == 0 && n > 0 && n < menu->max + 1)
+ if (mutt_atoi (buf, &n, 0) == 0 && n > 0 && n < menu->max + 1)
{
n--; /* msg numbers are 0-based */
menu->current = n;
diff --git a/mh.c b/mh.c
index 67e63824..1cea86ea 100644
--- a/mh.c
+++ b/mh.c
@@ -154,12 +154,12 @@ static int mh_read_token (char *t, int *first, int *last)
if ((p = strchr (t, '-')))
{
*p++ = '\0';
- if (mutt_atoi (t, first) < 0 || mutt_atoi (p, last) < 0)
+ if (mutt_atoi (t, first, 0) < 0 || mutt_atoi (p, last, 0) < 0)
return -1;
}
else
{
- if (mutt_atoi (t, first) < 0)
+ if (mutt_atoi (t, first, 0) < 0)
return -1;
*last = *first;
}
@@ -512,7 +512,7 @@ static void mh_update_sequences (CONTEXT * ctx)
else
p = ctx->hdrs[l]->path;
- if (mutt_atoi (p, &i) < 0)
+ if (mutt_atoi (p, &i, 0) < 0)
continue;
if (!ctx->hdrs[l]->read)
@@ -644,7 +644,7 @@ static void mh_update_maildir (struct maildir *md, struct mh_sequences *mhs)
else
p = md->h->path;
- if (mutt_atoi (p, &i) < 0)
+ if (mutt_atoi (p, &i, 0) < 0)
continue;
f = mhs_check (mhs, i);
diff --git a/parse.c b/parse.c
index 9bf01338..4ebaec57 100644
--- a/parse.c
+++ b/parse.c
@@ -753,7 +753,8 @@ static BODY *_parse_multipart (FILE *fp, const char *boundary, LOFF_T end_off,
#ifdef SUN_ATTACHMENT
if (mutt_get_parameter ("content-lines", new->parameter))
{
- mutt_atoi (mutt_get_parameter ("content-lines", new->parameter), &lines);
+ mutt_atoi (mutt_get_parameter ("content-lines", new->parameter),
+ &lines, 0);
for ( ; lines; lines-- )
if (ftello (fp) >= end_off || fgets (buffer, LONG_STRING, fp) == NULL)
break;
@@ -941,7 +942,7 @@ time_t mutt_parse_date (const char *s, HEADER *h)
switch (count)
{
case 0: /* day of the month */
- if (mutt_atoi (t, &tm.tm_mday) < 0 || tm.tm_mday < 0)
+ if (mutt_atoi (t, &tm.tm_mday, 0) < 0 || tm.tm_mday < 0)
return (-1);
if (tm.tm_mday > 31)
return (-1);
@@ -954,7 +955,7 @@ time_t mutt_parse_date (const char *s, HEADER *h)
break;
case 2: /* year */
- if (mutt_atoi (t, &tm.tm_year) < 0 || tm.tm_year < 0)
+ if (mutt_atoi (t, &tm.tm_year, 0) < 0 || tm.tm_year < 0)
return (-1);
if (tm.tm_year < 50)
tm.tm_year += 100;
@@ -1347,7 +1348,7 @@ int mutt_parse_rfc822_line (ENVELOPE *e, HEADER *hdr, char *line, char *p, short
* HACK - mutt has, for a very short time, produced negative
* Lines header values. Ignore them.
*/
- if (mutt_atoi (p, &hdr->lines) < 0 || hdr->lines < 0)
+ if (mutt_atoi (p, &hdr->lines, 0) < 0 || hdr->lines < 0)
hdr->lines = 0;
}
diff --git a/resize.c b/resize.c
index 01d84e46..120f967d 100644
--- a/resize.c
+++ b/resize.c
@@ -59,12 +59,12 @@ void mutt_resize_screen (void)
}
if (SLtt_Screen_Rows <= 0)
{
- if ((cp = getenv ("LINES")) != NULL && mutt_atoi (cp, &SLtt_Screen_Rows) < 0)
+ if ((cp = getenv ("LINES")) != NULL && mutt_atoi (cp, &SLtt_Screen_Rows, 0) < 0)
SLtt_Screen_Rows = 24;
}
if (SLtt_Screen_Cols <= 0)
{
- if ((cp = getenv ("COLUMNS")) != NULL && mutt_atoi (cp, &SLtt_Screen_Cols) < 0)
+ if ((cp = getenv ("COLUMNS")) != NULL && mutt_atoi (cp, &SLtt_Screen_Cols, 0) < 0)
SLtt_Screen_Cols = 80;
}
#ifdef USE_SLANG_CURSES
diff --git a/rfc2231.c b/rfc2231.c
index 68d051ca..426532bf 100644
--- a/rfc2231.c
+++ b/rfc2231.c
@@ -150,7 +150,7 @@ void rfc2231_decode_parameters (PARAMETER **headp)
thus an overflow should never occur in a valid message, thus
the value INT_MAX in case of overflow does not really matter
(the goal is just to avoid undefined behavior). */
- if (mutt_atoi (s, &index))
+ if (mutt_atoi (s, &index, 0) < 0)
index = INT_MAX;
conttmp = rfc2231_new_parameter ();
diff --git a/score.c b/score.c
index 5774d764..79985c39 100644
--- a/score.c
+++ b/score.c
@@ -117,7 +117,7 @@ int mutt_parse_score (BUFFER *buf, BUFFER *s, union pointer_long_t udata, BUFFER
ptr->exact = 1;
pc++;
}
- if (mutt_atoi (pc, &ptr->val) < 0)
+ if (mutt_atoi (pc, &ptr->val, 0) < 0)
{
FREE (&pattern);
strfcpy (err->data, _("Error: score: invalid number"), err->dsize);
diff --git a/smtp.c b/smtp.c
index 4ebd06f2..2ab45ec1 100644
--- a/smtp.c
+++ b/smtp.c
@@ -89,7 +89,7 @@ static int smtp_code (char *buf, size_t len, int *n)
code[1] = buf[1];
code[2] = buf[2];
code[3] = 0;
- if (mutt_atoi (code, n) < 0)
+ if (mutt_atoi (code, n, 0) < 0)
return -1;
return 0;
}
diff --git a/url.c b/url.c
index 9c8bcb4c..0eeb6d0b 100644
--- a/url.c
+++ b/url.c
@@ -162,7 +162,7 @@ static int ciss_parse_userhost (ciss_url_t *ciss, char *src)
{
int t;
*p++ = '\0';
- if (mutt_atoi (p, &t) < 0 || t < 0 || t > 0xffff)
+ if (mutt_atoi (p, &t, MUTT_ATOI_ALLOW_EMPTY) < 0 || t < 0 || t > 0xffff)
return -1;
ciss->port = (unsigned short)t;
}