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