From: Ian Jackson Date: Mon, 5 Dec 2016 22:47:34 +0000 (+0000) Subject: SECURITY: Do not overrun reading buffer if domain ends with backslash X-Git-Tag: adns-1.5.2~24 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=278f8eee581c4c4a0ddd0f98c4dc8c2974cf6b90;p=adns.git 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 --- 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])) {