From c2b4ccc0d125a30a1970f555f572bf74de27a3d5 Mon Sep 17 00:00:00 2001 From: bert hubert 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 mesg(new char[mesgsize]); DLOG(L<<"TCP Connection accepted on fd "<sizeof(mesg)) { + if(pktlen > mesgsize) { L<(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) {