a03026
From f2ad2cecb55825f7e4409222de1688b9ceebceda Mon Sep 17 00:00:00 2001
a03026
From: Simon Kelley <simon@thekelleys.org.uk>
a03026
Date: Mon, 25 Sep 2017 20:16:50 +0100
a03026
Subject: [PATCH 6/9]     Security fix, CVE-2017-14495, OOM in DNS response
a03026
 creation.
a03026
a03026
    Fix out-of-memory Dos vulnerability. An attacker which can
a03026
    send malicious DNS queries to dnsmasq can trigger memory
a03026
    allocations in the add_pseudoheader function
a03026
    The allocated memory is never freed which leads to a DoS
a03026
    through memory exhaustion. dnsmasq is vulnerable only
a03026
    if one of the following option is specified:
a03026
    --add-mac, --add-cpe-id or --add-subnet.
a03026
---
a03026
 src/edns0.c | 8 +++++++-
a03026
 1 file changed, 7 insertions(+), 1 deletion(-)
a03026
a03026
diff --git a/src/edns0.c b/src/edns0.c
a03026
index eed135e..5bdc133 100644
a03026
--- a/src/edns0.c
a03026
+++ b/src/edns0.c
a03026
@@ -192,9 +192,15 @@ size_t add_pseudoheader(struct dns_header *header, size_t plen, unsigned char *l
a03026
 	  !(p = skip_section(p, 
a03026
 			     ntohs(header->ancount) + ntohs(header->nscount) + ntohs(header->arcount), 
a03026
 			     header, plen)))
a03026
+      {
a03026
+	free(buff);
a03026
 	return plen;
a03026
+      }
a03026
       if (p + 11 > limit)
a03026
-       return plen; /* Too big */
a03026
+      {
a03026
+        free(buff);
a03026
+        return plen; /* Too big */
a03026
+      }
a03026
       *p++ = 0; /* empty name */
a03026
       PUTSHORT(T_OPT, p);
a03026
       PUTSHORT(udp_sz, p); /* max packet length, 512 if not given in EDNS0 header */
a03026
-- 
a03026
2.9.5
a03026