]> granicus.if.org Git - pdns/commitdiff
dnsdist: Get rid of a VLA in TCP workers
authorRemi Gacogne <remi.gacogne@powerdns.com>
Fri, 23 Mar 2018 09:42:49 +0000 (10:42 +0100)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Fri, 23 Mar 2018 09:42:49 +0000 (10:42 +0100)
pdns/dnsdist-tcp.cc

index b3b74864ebf338d83d14568213efd9b848705b63..124745f54c989047539b555e9b2282824a30574e 100644 (file)
@@ -271,6 +271,7 @@ void* tcpClientThread(int pipefd)
     size_t queriesCount = 0;
     time_t connectionStartTime = time(NULL);
     std::vector<char> queryBuffer;
+    std::vector<char> answerBuffer;
 
     if (getsockname(ci.fd, (sockaddr*)&dest, &len)) {
       dest = ci.cs->local;
@@ -559,9 +560,9 @@ void* tcpClientThread(int pipefd)
         }
 #endif
         responseSize += addRoom;
-        char answerbuffer[responseSize];
-        readn2WithTimeout(dsock, answerbuffer, rlen, ds->tcpRecvTimeout);
-        char* response = answerbuffer;
+        answerBuffer.resize(responseSize);
+        char* response = &answerBuffer.at(0);
+        readn2WithTimeout(dsock, response, rlen, ds->tcpRecvTimeout);
         uint16_t responseLen = rlen;
         if (outstanding) {
           /* might be false for {A,I}XFR */