Ensure INTERNALDATE and RFC822.SIZE field sizes fit temp buffer.
Thanks to Jeriko One for the bug report and patch, which this patch is
based upon.
{
char tmp[SHORT_STRING];
char *ptmp;
+ size_t dlen;
if (!s)
return -1;
}
s++;
ptmp = tmp;
- while (*s && *s != '\"')
+ dlen = sizeof(tmp) - 1;
+ while (*s && *s != '\"' && dlen)
+ {
*ptmp++ = *s++;
+ dlen--;
+ }
if (*s != '\"')
return -1;
s++; /* skip past the trailing " */
s += 11;
SKIPWS (s);
ptmp = tmp;
- while (isdigit ((unsigned char) *s))
+ dlen = sizeof(tmp) - 1;
+ while (isdigit ((unsigned char) *s) && dlen)
+ {
*ptmp++ = *s++;
+ dlen--;
+ }
*ptmp = 0;
if (mutt_atol (tmp, &h->content_length) < 0)
return -1;