If the rfc2047_decode_word() function fails, only the failed word is
copied into the output.
In the previous version, the rest of the header was copied as well,
which resulted in repetition in the output. This repetition, combined
with the lack of checking the length of the output buffer, could have
led to writing outside the allocated memory.
}
if (rfc2047_decode_word (d, p, dlen) < 0)
- strcpy(d, p);
+ {
+ n = q - p;
+ if (n > dlen)
+ n = dlen;
+ memcpy (d, p, n);
+ }
found_encoded = 1;
s = q;
n = strlen (d);