diff options
Diffstat (limited to 'testing/pdns/allocate-tcp-buffer-dynamically.patch')
-rw-r--r-- | testing/pdns/allocate-tcp-buffer-dynamically.patch | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/testing/pdns/allocate-tcp-buffer-dynamically.patch b/testing/pdns/allocate-tcp-buffer-dynamically.patch new file mode 100644 index 0000000000..b346a2e9a1 --- /dev/null +++ b/testing/pdns/allocate-tcp-buffer-dynamically.patch @@ -0,0 +1,46 @@ +From c2b4ccc0d125a30a1970f555f572bf74de27a3d5 Mon Sep 17 00:00:00 2001 +From: bert hubert <bert.hubert@netherlabs.nl> +Date: Sat, 10 Jan 2015 23:06:38 +0100 +Subject: [PATCH] allocate TCP buffer dynamically, decreasing our stack usage + +--- + pdns/tcpreceiver.cc | 9 +++++---- + 1 file changed, 5 insertions(+), 4 deletions(-) + +diff --git a/pdns/tcpreceiver.cc b/pdns/tcpreceiver.cc +index f90bf90..6356d34 100644 +--- a/pdns/tcpreceiver.cc ++++ b/pdns/tcpreceiver.cc +@@ -253,7 +253,8 @@ void *TCPNameserver::doConnection(void *data) + pthread_detach(pthread_self()); + Utility::setNonBlocking(fd); + try { +- char mesg[65535]; ++ int mesgsize=65535; ++ scoped_array<char> mesg(new char[mesgsize]); + + DLOG(L<<"TCP Connection accepted on fd "<<fd<<endl); + bool logDNSQueries= ::arg().mustDo("log-dns-queries"); +@@ -278,19 +279,19 @@ void *TCPNameserver::doConnection(void *data) + + // do not remove this check as it will catch if someone + // decreases the mesg buffer size for some reason. +- if(pktlen>sizeof(mesg)) { ++ if(pktlen > mesgsize) { + L<<Logger::Error<<"Received an overly large question from "<<remote.toString()<<", dropping"<<endl; + break; + } + +- getQuestion(fd, mesg, pktlen, remote); ++ getQuestion(fd, mesg.get(), pktlen, remote); + S.inc("tcp-queries"); + + packet=shared_ptr<DNSPacket>(new DNSPacket); + packet->setRemote(&remote); + packet->d_tcp=true; + packet->setSocket(fd); +- if(packet->parse(mesg, pktlen)<0) ++ if(packet->parse(mesg.get(), pktlen)<0) + break; + + if(packet->qtype.getCode()==QType::AXFR) { |