libfetch: disallow invalid escape sequences
Per RFC1738 escape is "% hex hex"; other sequences do not form a valid URL. Suggested by: Matthew Dillon Reviewed by: Matthew Dillon MFC after: 1 week
This commit is contained in:
parent
690a8a6acd
commit
83372bda16
@ -327,6 +327,9 @@ fetch_pctdecode(char *dst, const char *src, size_t dlen)
|
||||
(d2 = fetch_hexval(s[2])) >= 0 && (d1 > 0 || d2 > 0)) {
|
||||
c = d1 << 4 | d2;
|
||||
s += 2;
|
||||
} else if (s[0] == '%') {
|
||||
/* Invalid escape sequence. */
|
||||
return (NULL);
|
||||
} else {
|
||||
c = *s;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user