Commit 3ffc27d5 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp Committed by Dridi Boukelmoune

Slight polish

Conflicts:
	lib/libvmod_blob/hex.c
parent a6ab945e
...@@ -108,7 +108,7 @@ hex_decode(const enum encoding dec, char *restrict const buf, ...@@ -108,7 +108,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;
va_list ap2; va_list ap2;
AN(buf); AN(buf);
...@@ -122,26 +122,20 @@ hex_decode(const enum encoding dec, char *restrict const buf, ...@@ -122,26 +122,20 @@ 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;
} }
va_end(ap2); va_end(ap2);
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