From 82cd68fdf9d598318ff26b8edda88cb564ea4ec0 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 de265d9fc1..766b972616 100644 --- a/bin/tests/dst/t_dst.c +++ b/bin/tests/dst/t_dst.c @@ -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);