Commit 0e0e007c authored by Geoff Simmons's avatar Geoff Simmons

only check for out of workspace in URL decode when it's necessary

parent 3d1dfa39
......@@ -133,16 +133,17 @@ url_decode(const enum encoding dec, char *restrict const buf,
while (*s && len) {
uint8_t nib2;
if (dest + 1 > end) {
errno = ENOMEM;
return -1;
}
switch(state) {
case NORMAL:
if (*s == '%')
state = PERCENT;
else
else {
if (dest == end) {
errno = ENOMEM;
return -1;
}
*dest++ = *s;
}
break;
case PERCENT:
if (isoutofrange(*s)
......@@ -153,6 +154,10 @@ url_decode(const enum encoding dec, char *restrict const buf,
state = FIRSTNIB;
break;
case FIRSTNIB:
if (dest == end) {
errno = ENOMEM;
return -1;
}
if (isoutofrange(*s)
|| (nib2 = nibble[*s - '0']) == 0xff) {
errno = EINVAL;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment