improve error handling in sig_fromfile

(cherry picked from commit 52c5b74c27)
This commit is contained in:
Mark Andrews 2014-04-29 14:41:25 +10:00
parent 97e241a3f8
commit 82cd68fdf9

View file

@ -673,23 +673,28 @@ sig_fromfile(char *path, isc_buffer_t *iscbuf) {
p = buf;
len = size;
while(len) {
while (len > 0) {
if ((*p == '\r') || (*p == '\n')) {
++p;
--len;
continue;
}
} else if (len < 2)
return (1);
if (('0' <= *p) && (*p <= '9'))
val = *p - '0';
else
else if (('A' <= *p) && (*p <= 'F'))
val = *p - 'A' + 10;
else
return (1);
++p;
val <<= 4;
--len;
if (('0' <= *p) && (*p <= '9'))
val |= (*p - '0');
else
else if (('A' <= *p) && (*p <= 'F'))
val |= (*p - 'A' + 10);
else
return (1);
++p;
--len;
isc_buffer_putuint8(iscbuf, val);