From: Remi Gacogne Date: Tue, 5 Dec 2017 16:07:19 +0000 (+0100) Subject: dnsreplay: Bail out on a too small outgoing buffer X-Git-Tag: dnsdist-1.3.1~113^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F6580%2Fhead;p=thirdparty%2Fpdns.git dnsreplay: Bail out on a too small outgoing buffer --- diff --git a/pdns/dnsreplay.cc b/pdns/dnsreplay.cc index a95a233f34..99ddaffad4 100644 --- a/pdns/dnsreplay.cc +++ b/pdns/dnsreplay.cc @@ -590,7 +590,7 @@ static void addECSOption(char* packet, const size_t& packetSize, uint16_t* len, uint16_t arcount = ntohs(dh->arcount); /* does it fit in the existing buffer? */ - if (packetSize - *len > EDNSRR.size()) { + if (packetSize > *len && packetSize - *len > EDNSRR.size()) { arcount++; dh->arcount = htons(arcount); memcpy(packet + *len, EDNSRR.c_str(), EDNSRR.size());