Commit 931ead58 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Slight polish

parent 4c814318
...@@ -109,7 +109,7 @@ hex_decode(const enum encoding dec, char *restrict const buf, ...@@ -109,7 +109,7 @@ hex_decode(const enum encoding dec, char *restrict const buf,
char *dest = buf; char *dest = buf;
const char *b; const char *b;
unsigned char extranib = 0; unsigned char extranib = 0;
ssize_t len = 0; size_t len = 0;
AN(buf); AN(buf);
AN(strings); AN(strings);
...@@ -123,25 +123,19 @@ hex_decode(const enum encoding dec, char *restrict const buf, ...@@ -123,25 +123,19 @@ hex_decode(const enum encoding dec, char *restrict const buf,
b = s; b = s;
while (*s) { while (*s) {
if (!isxdigit(*s++)) { if (!isxdigit(*s++)) {
len = -1; errno = EINVAL;
break; return (-1);
} }
} }
if (len == -1)
break;
len += s - b; len += s - b;
} }
if (len == 0) if (len == 0)
return 0; return 0;
if (len == -1) {
errno = EINVAL;
return -1;
}
if (n != -1 && len > n) if (n != -1 && len > n)
len = n; len = n;
if ((len+1) >> 1 > buflen) { if (((len+1) >> 1) > buflen) {
errno = ENOMEM; errno = ENOMEM;
return -1; return -1;
} }
......
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