From 2c001eb60c4929ddc280da091582f37fb5e82072 Mon Sep 17 00:00:00 2001 From: Remi Gacogne Date: Fri, 23 Mar 2018 12:21:51 +0100 Subject: [PATCH] auth: Remove VLAs --- modules/pipebackend/coprocess.cc | 4 ++-- modules/remotebackend/pipeconnector.cc | 4 ++-- pdns/common_startup.cc | 4 +++- pdns/dnstcpbench.cc | 2 +- pdns/nameserver.cc | 7 +++---- pdns/nameserver.hh | 2 +- pdns/pkcs11signers.cc | 4 ++-- pdns/rfc2136handler.cc | 6 +++--- 8 files changed, 17 insertions(+), 16 deletions(-) diff --git a/modules/pipebackend/coprocess.cc b/modules/pipebackend/coprocess.cc index ecc7e1089..029a8b8da 100644 --- a/modules/pipebackend/coprocess.cc +++ b/modules/pipebackend/coprocess.cc @@ -45,13 +45,13 @@ CoProcess::CoProcess(const string &command,int timeout, int infd, int outfd) vector v; split(v, command, is_any_of(" ")); - const char *argv[v.size()+1]; + std::vectorargv(v.size()+1); argv[v.size()]=0; for (size_t n = 0; n < v.size(); n++) argv[n]=v[n].c_str(); // we get away with not copying since nobody resizes v - launch(argv, timeout, infd, outfd); + launch(&argv.at(0), timeout, infd, outfd); } void CoProcess::launch(const char **argv, int timeout, int infd, int outfd) diff --git a/modules/remotebackend/pipeconnector.cc b/modules/remotebackend/pipeconnector.cc index 54cdb0319..ba3aaba9a 100644 --- a/modules/remotebackend/pipeconnector.cc +++ b/modules/remotebackend/pipeconnector.cc @@ -64,7 +64,7 @@ void PipeConnector::launch() { std::vector v; split(v, command, is_any_of(" ")); - const char *argv[v.size()+1]; + std::vectorargv(v.size()+1); argv[v.size()]=0; for (size_t n = 0; n < v.size(); n++) @@ -107,7 +107,7 @@ void PipeConnector::launch() { // stdin & stdout are now connected, fire up our coprocess! - if(execv(argv[0], const_cast(argv))<0) // now what + if(execv(argv[0], const_cast(&argv[0]))<0) // now what exit(123); /* not a lot we can do here. We shouldn't return because that will leave a forked process around. diff --git a/pdns/common_startup.cc b/pdns/common_startup.cc index 4c74222c9..6c7a7ec49 100644 --- a/pdns/common_startup.cc +++ b/pdns/common_startup.cc @@ -366,6 +366,8 @@ try int diff; bool logDNSQueries = ::arg().mustDo("log-dns-queries"); shared_ptr NS; + std::string buffer; + buffer.resize(DNSPacket::s_udpTruncationThreshold); // If we have SO_REUSEPORT then create a new port for all receiver threads // other than the first one. @@ -379,7 +381,7 @@ try } for(;;) { - if(!(P=NS->receive(&question))) { // receive a packet inline + if(!(P=NS->receive(&question, buffer))) { // receive a packet inline continue; // packet was broken, try again } diff --git a/pdns/dnstcpbench.cc b/pdns/dnstcpbench.cc index fbeba1ba5..2c6e7fb42 100644 --- a/pdns/dnstcpbench.cc +++ b/pdns/dnstcpbench.cc @@ -250,7 +250,7 @@ try } - pthread_t workers[numworkers]; + std::vector workers(numworkers); FILE* fp; if(!g_vm.count("file")) diff --git a/pdns/nameserver.cc b/pdns/nameserver.cc index a37720ccb..2c0501de3 100644 --- a/pdns/nameserver.cc +++ b/pdns/nameserver.cc @@ -303,12 +303,11 @@ void UDPNameserver::send(DNSPacket *p) L< rfds= d_rfds; @@ -378,7 +377,7 @@ DNSPacket *UDPNameserver::receive(DNSPacket *prefilled) else packet->d_dt.set(); // timing - if(packet->parse(mesg, (size_t) len)<0) { + if(packet->parse(&buffer.at(0), (size_t) len)<0) { S.inc("corrupt-packets"); S.ringAccount("remotes-corrupt", packet->d_remote); diff --git a/pdns/nameserver.hh b/pdns/nameserver.hh index b5b855555..d9d04198f 100644 --- a/pdns/nameserver.hh +++ b/pdns/nameserver.hh @@ -81,7 +81,7 @@ class UDPNameserver { public: UDPNameserver( bool additional_socket = false ); //!< Opens the socket - DNSPacket *receive(DNSPacket *prefilled=0); //!< call this in a while or for(;;) loop to get packets + DNSPacket *receive(DNSPacket *prefilled, std::string& buffer); //!< call this in a while or for(;;) loop to get packets void send(DNSPacket *); //!< send a DNSPacket. Will call DNSPacket::truncate() if over 512 bytes inline bool canReusePort() { #ifdef SO_REUSEPORT diff --git a/pdns/pkcs11signers.cc b/pdns/pkcs11signers.cc index 26288e72a..4ad764c48 100644 --- a/pdns/pkcs11signers.cc +++ b/pdns/pkcs11signers.cc @@ -672,8 +672,8 @@ CK_RV Pkcs11Slot::HuntSlot(const string& tokenId, CK_SLOT_ID &slotId, _CK_SLOT_I } // get the actual slot ids - CK_SLOT_ID slotIds[slots]; - err = functions->C_GetSlotList(CK_FALSE, slotIds, &slots); + std::vector slotIds(slots); + err = functions->C_GetSlotList(CK_FALSE, &slotIds.at(0), &slots); if (err) { L<(recvRes)); + MOADNSParser mdp(false, buffer.data(), static_cast(recvRes)); L<