dnsmasq: forward.c: fix CVE-2017-13704
[openwrt/openwrt.git] / package / network / services / dnsmasq / patches / 025-fix-CVE-2017-13704.patch
1 From 38af9b1ac3242a4128e88069c495024caa565f0e Mon Sep 17 00:00:00 2001
2 From: Kevin Darbyshire-Bryant <kevin@darbyshire-bryant.me.uk>
3 Date: Tue, 29 Aug 2017 12:35:40 +0100
4 Subject: [PATCH] forward.c: fix CVE-2017-13704
5
6 Fix SIGSEGV in rfc1035.c answer_request() line 1228 where memset()
7 is called with header & limit pointing at the same address and thus
8 tries to clear memory from before the buffer begins.
9
10 answer_request() is called with an invalid edns packet size provided by
11 the client. Ensure the udp_size provided by the client is bounded by
12 512 and configured maximum as per RFC 6891 6.2.3 "Values lower than 512
13 MUST be treated as equal to 512"
14
15 The client that exposed the problem provided a payload udp size of 0.
16
17 Signed-off-by: Kevin Darbyshire-Bryant <kevin@darbyshire-bryant.me.uk>
18 ---
19 src/forward.c | 2 ++
20 1 file changed, 2 insertions(+)
21
22 diff --git a/src/forward.c b/src/forward.c
23 index f22556a..62c5a5a 100644
24 --- a/src/forward.c
25 +++ b/src/forward.c
26 @@ -1408,6 +1408,8 @@ void receive_query(struct listener *listen, time_t now)
27 defaults to 512 */
28 if (udp_size > daemon->edns_pktsz)
29 udp_size = daemon->edns_pktsz;
30 + if (udp_size < 512)
31 + udp_size = 512; /* RFC 6891 6.2.3 */
32 }
33
34 #ifdef HAVE_AUTH
35 --
36 2.7.4
37