From: Remi Gacogne Date: Mon, 27 Aug 2018 21:35:49 +0000 (+0200) Subject: ixfrdist: Fix invalid buffer usage in getSerialFromMaster() X-Git-Tag: dnsdist-1.3.3~145^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F6886%2Fhead;p=thirdparty%2Fpdns.git ixfrdist: Fix invalid buffer usage in getSerialFromMaster() --- diff --git a/pdns/ixfrutils.cc b/pdns/ixfrutils.cc index 180b494291..04c832451d 100644 --- a/pdns/ixfrutils.cc +++ b/pdns/ixfrutils.cc @@ -49,10 +49,14 @@ uint32_t getSerialFromMaster(const ComboAddress& master, const DNSName& zone, sh s.writen(msg); string reply; - char buf[4096]; + reply.resize(4096); // will throw a NetworkError on timeout - s.readWithTimeout(buf, sizeof(buf), timeout); - reply.assign(buf); + ssize_t got = s.readWithTimeout(&reply[0], reply.size(), timeout); + if (got < 0 || static_cast(got) < sizeof(dnsheader)) { + throw std::runtime_error("Invalid response size " + std::to_string(got)); + } + + reply.resize(got); MOADNSParser mdp(false, reply); if(mdp.d_header.rcode) {