From f9c57c98da1b1007a51680629b667d57d9b702b8 Mon Sep 17 00:00:00 2001 From: Remi Gacogne Date: Tue, 5 Dec 2017 17:07:19 +0100 Subject: [PATCH] dnsreplay: Bail out on a too small outgoing buffer --- pdns/dnsreplay.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pdns/dnsreplay.cc b/pdns/dnsreplay.cc index 4c5f218c9..a671472f6 100644 --- a/pdns/dnsreplay.cc +++ b/pdns/dnsreplay.cc @@ -595,7 +595,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()); -- 2.49.0