]> granicus.if.org Git - pdns/commitdiff
ixfr: Get rid of a VLA (and two copies) in getIXFRDeltas()
authorRemi Gacogne <remi.gacogne@powerdns.com>
Fri, 23 Mar 2018 10:16:03 +0000 (11:16 +0100)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Fri, 23 Mar 2018 10:16:03 +0000 (11:16 +0100)
pdns/ixfr.cc

index 8d02a8bf500d2db206b90f3eb750919b2a5f0991..56a69c1df5fae23e89803c84cfb9d2ec152bb8c1 100644 (file)
@@ -169,6 +169,7 @@ vector<pair<vector<DNSRecord>, vector<DNSRecord> > > getIXFRDeltas(const ComboAd
   vector<DNSRecord> records;
   size_t receivedBytes = 0;
   int8_t ixfrInProgress = -2;
+  std::string reply;
 
   for(;;) {
     // IXFR end
@@ -186,18 +187,18 @@ vector<pair<vector<DNSRecord>, vector<DNSRecord> > > 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: "<<mdp.d_header.rcode<<", got "<<mdp.d_answers.size()<<" answers"<<endl;
 
     if(!tt.algo.empty()) { // TSIG verify message
-      tsigVerifier.check(std::string(reply, len), mdp);
+      tsigVerifier.check(reply, mdp);
     }
 
     for(auto& r: mdp.d_answers) {