File adns-1.5.1-CVE-2017-9107.patch of Package adns.15332
From 278f8eee581c4c4a0ddd0f98c4dc8c2974cf6b90 Mon Sep 17 00:00:00 2001
From: Ian Jackson <ijackson@chiark.greenend.org.uk>
Date: Mon, 5 Dec 2016 22:47:34 +0000
Subject: [PATCH 09/32] SECURITY: Do not overrun reading buffer if domain ends
with backslash
If the query domain ended with \, and adns_qf_quoteok_query was
specified, qdparselabel would read additional bytes from the buffer
and try to treat them as the escape sequence. It would depart the
input buffer and start processing many bytes of arbitrary heap data as
if it were the query domain.
Eventually it would run out of input or find some other kind of error,
and declare the query domain invalid. But before then it might outrun
available memory and crash.
In principle this could be a denial of service attack.
Found by AFL 2.35b. CVE-2017-9107.
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
---
src/transmit.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/transmit.c b/src/transmit.c
index 33c3329..4984986 100644
--- a/src/transmit.c
+++ b/src/transmit.c
@@ -87,6 +87,7 @@ static adns_status qdparselabel(adns_state ads,
while (p!=pe && (c= *p++)!='.') {
if (c=='\\') {
if (!(flags & adns_qf_quoteok_query)) return adns_s_querydomaininvalid;
+ if (p==pe) return adns_s_querydomaininvalid;
if (ctype_digit(p[0])) {
if (p+1==pe || p+2==pe) return adns_s_querydomaininvalid;
if (ctype_digit(p[1]) && ctype_digit(p[2])) {
--
2.20.1