Commit 8fcf8eda authored by Kevin J. McCarthy's avatar Kevin J. McCarthy

Change imap literal counts to parse and store unsigned ints.

IMAP literals are of type number.  Change imap_get_literal_count() to
use mutt_atoui() instead of atoi().  Change the return type variables
used to store the count to type unsigned int.

It's doubtful this was a real issue, but as long as we're cleaning up
incorrect atoi() usage, we should fix this too.
parent b8190ef3
......@@ -729,7 +729,7 @@ static void cmd_parse_list (IMAP_DATA* idata, char* s)
IMAP_LIST* list;
IMAP_LIST lb;
char delimbuf[5]; /* worst case: "\\"\0 */
long litlen;
unsigned int litlen;
if (idata->cmddata && idata->cmdtype == IMAP_CT_LIST)
list = (IMAP_LIST*)idata->cmddata;
......@@ -936,7 +936,7 @@ static void cmd_parse_status (IMAP_DATA* idata, char* s)
unsigned int count;
IMAP_STATUS *status;
unsigned int olduv, oldun;
long litlen;
unsigned int litlen;
short new = 0;
short new_msg_count = 0;
......
......@@ -199,9 +199,9 @@ void imap_logout_all (void)
/* imap_read_literal: read bytes bytes from server into file. Not explicitly
* buffered, relies on FILE buffering. NOTE: strips \r from \r\n.
* Apparently even literals use \r\n-terminated strings ?! */
int imap_read_literal (FILE* fp, IMAP_DATA* idata, long bytes, progress_t* pbar)
int imap_read_literal (FILE* fp, IMAP_DATA* idata, unsigned int bytes, progress_t* pbar)
{
long pos;
unsigned int pos;
char c;
int r = 0;
......
......@@ -246,7 +246,7 @@ int imap_exec_msgset (IMAP_DATA* idata, const char* pre, const char* post,
int imap_open_connection (IMAP_DATA* idata);
void imap_close_connection (IMAP_DATA* idata);
IMAP_DATA* imap_conn_find (const ACCOUNT* account, int flags);
int imap_read_literal (FILE* fp, IMAP_DATA* idata, long bytes, progress_t*);
int imap_read_literal (FILE* fp, IMAP_DATA* idata, unsigned int bytes, progress_t*);
void imap_expunge_mailbox (IMAP_DATA* idata);
void imap_logout (IMAP_DATA** idata);
int imap_sync_message_for_copy (IMAP_DATA *idata, HEADER *hdr, BUFFER *cmd,
......@@ -294,7 +294,7 @@ char* imap_fix_path (IMAP_DATA* idata, const char* mailbox, char* path,
size_t plen);
void imap_cachepath(IMAP_DATA* idata, const char* mailbox, char* dest,
size_t dlen);
int imap_get_literal_count (const char* buf, long* bytes);
int imap_get_literal_count (const char* buf, unsigned int* bytes);
char* imap_get_qualifier (char* buf);
int imap_mxcmp (const char* mx1, const char* mx2);
char* imap_next_word (char* s);
......
......@@ -529,7 +529,7 @@ int imap_fetch_message (CONTEXT *ctx, MESSAGE *msg, int msgno)
char buf[LONG_STRING];
char path[_POSIX_PATH_MAX];
char *pc;
long bytes;
unsigned int bytes;
progress_t progressbar;
unsigned int uid;
int cacheno;
......@@ -1234,7 +1234,7 @@ char* imap_set_flags (IMAP_DATA* idata, HEADER* h, char* s)
static int msg_fetch_header (CONTEXT* ctx, IMAP_HEADER* h, char* buf, FILE* fp)
{
IMAP_DATA* idata;
long bytes;
unsigned int bytes;
int rc = -1; /* default now is that string isn't FETCH response*/
int parse_rc;
......
......@@ -476,7 +476,7 @@ void imap_cachepath(IMAP_DATA* idata, const char* mailbox, char* dest,
/* imap_get_literal_count: write number of bytes in an IMAP literal into
* bytes, return 0 on success, -1 on failure. */
int imap_get_literal_count(const char *buf, long *bytes)
int imap_get_literal_count(const char *buf, unsigned int *bytes)
{
char *pc;
char *pn;
......@@ -489,7 +489,8 @@ int imap_get_literal_count(const char *buf, long *bytes)
while (isdigit ((unsigned char) *pc))
pc++;
*pc = 0;
*bytes = atoi(pn);
if (mutt_atoui (pn, bytes) < 0)
return -1;
return 0;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment