From 32fc3b0370c1992d1f81e2213d51d773180a0c61 Mon Sep 17 00:00:00 2001 From: Remi Gacogne Date: Fri, 23 Mar 2018 11:16:03 +0100 Subject: [PATCH] ixfr: Get rid of a VLA (and two copies) in getIXFRDeltas() --- pdns/ixfr.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pdns/ixfr.cc b/pdns/ixfr.cc index 8d02a8bf5..56a69c1df 100644 --- a/pdns/ixfr.cc +++ b/pdns/ixfr.cc @@ -169,6 +169,7 @@ vector, vector > > getIXFRDeltas(const ComboAd vector records; size_t receivedBytes = 0; int8_t ixfrInProgress = -2; + std::string reply; for(;;) { // IXFR end @@ -186,18 +187,18 @@ vector, vector > > getIXFRDeltas(const ComboAd if (maxReceivedBytes > 0 && (maxReceivedBytes - receivedBytes) < (size_t) len) throw std::runtime_error("Reached the maximum number of received bytes in an IXFR delta for zone '"+zone.toLogString()+"' from master "+master.toStringWithPort()); - char reply[len]; - readn2(s.getHandle(), reply, len); + reply.resize(len); + readn2(s.getHandle(), &reply.at(0), len); receivedBytes += len; - MOADNSParser mdp(false, string(reply, len)); + MOADNSParser mdp(false, reply); if(mdp.d_header.rcode) throw std::runtime_error("Got an error trying to IXFR zone '"+zone.toLogString()+"' from master '"+master.toStringWithPort()+"': "+RCode::to_s(mdp.d_header.rcode)); // cout<<"Got a response, rcode: "<