Skip to content

Commit

Permalink
Don't overflow stack buffer in msg_parse_fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
jeriko-one authored and flatcap committed Jul 7, 2018
1 parent 57971db commit 1b0f0d0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions imap/message.c
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ static int msg_parse_fetch(struct ImapHeader *h, char *s)
}
s++;
ptmp = tmp;
while (*s && *s != '\"')
while (*s && (*s != '\"') && (ptmp != (tmp + sizeof(tmp) - 1)))
*ptmp++ = *s++;
if (*s != '\"')
return -1;
Expand All @@ -343,7 +343,7 @@ static int msg_parse_fetch(struct ImapHeader *h, char *s)
s += 11;
SKIPWS(s);
ptmp = tmp;
while (isdigit((unsigned char) *s))
while (isdigit((unsigned char) *s) && (ptmp != (tmp + sizeof(tmp) - 1)))
*ptmp++ = *s++;
*ptmp = '\0';
if (mutt_str_atol(tmp, &h->content_length) < 0)
Expand Down

0 comments on commit 1b0f0d0

Please sign in to comment.