e87dd3
From 8c8fe650dc17aad0fbafc920fde719218dc4568d Mon Sep 17 00:00:00 2001
e87dd3
From: Simon Kelley <simon@thekelleys.org.uk>
e87dd3
Date: Mon, 25 Sep 2017 20:05:11 +0100
e87dd3
Subject: [PATCH 4/9]     Security fix, CVE-2017-14494, Infoleak handling
e87dd3
 DHCPv6 forwarded requests.
e87dd3
e87dd3
    Fix information leak in DHCPv6. A crafted DHCPv6 packet can
e87dd3
    cause dnsmasq to forward memory from outside the packet
e87dd3
    buffer to a DHCPv6 server when acting as a relay.
e87dd3
---
e87dd3
 src/rfc3315.c | 3 +++
e87dd3
 1 file changed, 3 insertions(+)
e87dd3
e87dd3
diff --git a/src/rfc3315.c b/src/rfc3315.c
e87dd3
index 8d18a28..03b3f84 100644
e87dd3
--- a/src/rfc3315.c
e87dd3
+++ b/src/rfc3315.c
e87dd3
@@ -216,6 +216,9 @@ static int dhcp6_maybe_relay(struct state *state, void *inbuff, size_t sz,
e87dd3
   
e87dd3
   for (opt = opts; opt; opt = opt6_next(opt, end))
e87dd3
     {
e87dd3
+      if (opt6_ptr(opt, 0) + opt6_len(opt) >= end) {
e87dd3
+        return 0;
e87dd3
+      }
e87dd3
       int o = new_opt6(opt6_type(opt));
e87dd3
       if (opt6_type(opt) == OPTION6_RELAY_MSG)
e87dd3
 	{
e87dd3
-- 
e87dd3
2.9.5
e87dd3