Fix buffer over-read in percent_decode().

When decoding a trigram, percent_decode() would correctly increment the input pointer by an extra two characters (three total) but would not decrement the input length by the same amount.  This would result in a buffer over-read when decoding unterminated strings.
This commit is contained in:
Dag-Erling Smørgrav 2016-01-10 23:29:03 +01:00
parent 476374323d
commit c044f2580b

View file

@ -92,6 +92,7 @@ percent_decode(const char *in, size_t ilen, char *out, size_t *olen)
if (++len < *olen && out != NULL)
*out++ = unhex(in[1]) << 4 | unhex(in[2]);
in += 2;
ilen -= 2;
} else {
if (*olen > 0 && out != NULL)
*out = '\0';