diff options
author | Kevin McCarthy <kevin@8t8.us> | 2021-01-26 12:58:54 -0800 |
---|---|---|
committer | Kevin McCarthy <kevin@8t8.us> | 2021-01-27 13:54:38 -0800 |
commit | 5d73e4cf196abcfe2ef2a39ce2233ac080156cdb (patch) | |
tree | 74f8a8bec78f73efd66c6b4b041e5f0569ca63b7 /imap/message.c | |
parent | 7737b353357f6d8d6a86d5822d4afb98c4e444ef (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.
Diffstat (limited to 'imap/message.c')
-rw-r--r-- | imap/message.c | 10 |
1 files changed, 5 insertions, 5 deletions
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) || |