From eefcfe0499ed5bae629e124d06c41620ff554c1c Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Tue, 29 Apr 2014 14:41:25 +1000 Subject: [PATCH] improve error handling in sig_fromfile (cherry picked from commit 52c5b74c27305999a45ab86051ef32913443fa0a) --- bin/tests/dst/t_dst.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/bin/tests/dst/t_dst.c b/bin/tests/dst/t_dst.c index 47a3d49b57..4e69c2ddc4 100644 --- a/bin/tests/dst/t_dst.c +++ b/bin/tests/dst/t_dst.c @@ -671,23 +671,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);