From 288b4564e462b534a493d6527cb044dc5aabfd2e Mon Sep 17 00:00:00 2001 From: Dirk Ziegelmeier Date: Wed, 10 Feb 2016 20:41:31 +0100 Subject: [PATCH] DNS: Fix potential array out of bounds access. Variable nanswers may contain bogus values. (found by Coverity) --- src/core/dns.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/dns.c b/src/core/dns.c index 3a6c3f9c..d442cd12 100644 --- a/src/core/dns.c +++ b/src/core/dns.c @@ -1129,7 +1129,7 @@ dns_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr, /* skip the rest of the "question" part */ res_idx += SIZEOF_DNS_QUERY; - while (nanswers > 0) { + while ((nanswers > 0) && (res_idx < p->tot_len)) { /* skip answer resource record's host name */ res_idx = dns_parse_name(p, res_idx);