]> granicus.if.org Git - pdns/commitdiff
dnsreplay: Bail out on a too small outgoing buffer
authorRemi Gacogne <remi.gacogne@powerdns.com>
Tue, 5 Dec 2017 16:07:19 +0000 (17:07 +0100)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Tue, 8 May 2018 13:16:39 +0000 (15:16 +0200)
pdns/dnsreplay.cc

index a95a233f344de47f425b4c139ffdad83a73478e0..99ddaffad4edfe3817746c7c6b47e97641f868b1 100644 (file)
@@ -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());