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: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e594beffdcdaca435ddb4f975b22634b53b5a699;p=pdns dnsreplay: Bail out on a too small outgoing buffer --- diff --git a/pdns/dnsreplay.cc b/pdns/dnsreplay.cc index a95a233f3..99ddaffad 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());