kdc: de_http stricter parsing

In de_http() treat any sequence of '%' not followed by two hex digits
as invalid.

Change-Id: I812665c1a2806f8daba06d267bbee57287aa2314
This commit is contained in:
Jeffrey Altman
2017-01-25 17:53:59 -05:00
committed by Viktor Dukhovni
parent 097e96cbf4
commit ebae52f3cc

View File

@@ -515,15 +515,21 @@ static int
de_http(char *buf)
{
unsigned char *p, *q;
for(p = q = (unsigned char *)buf; *p; p++, q++) {
if(*p == '%' && isxdigit(p[1]) && isxdigit(p[2])) {
unsigned int x;
if(sscanf((char *)p + 1, "%2x", &x) != 1)
unsigned int x;
for (p = q = (unsigned char *)buf; *p; p++, q++) {
if (*p == '%') {
if (!(isxdigit(p[1]) && isxdigit(p[2])))
return -1;
if (sscanf((char *)p + 1, "%2x", &x) != 1)
return -1;
*q = x;
p += 2;
} else
} else {
*q = *p;
}
}
*q = '\0';
return 0;