]> granicus.if.org Git - pdns/commitdiff
plug memory leak on packet building error caused by bogus database information
authorBert Hubert <bert.hubert@netherlabs.nl>
Thu, 2 Aug 2007 21:29:10 +0000 (21:29 +0000)
committerBert Hubert <bert.hubert@netherlabs.nl>
Thu, 2 Aug 2007 21:29:10 +0000 (21:29 +0000)
git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@1079 d19b8d6e-7fed-0310-83ef-9ca221ded41b

pdns/packethandler.cc

index 91ce4690f56cde184faa25316420b041ab6a561d..ae67b4ea2e42d9404635f500c6739775f7acb228 100644 (file)
@@ -896,6 +896,7 @@ DNSPacket *PacketHandler::questionOrRecurse(DNSPacket *p, bool *shouldRecurse)
   sendit:;
     if(doAdditionalProcessingAndDropAA(p,r)<0)
       return 0;
+
     r->wrapup(); // needed for inserting in cache
     if(!noCache)
       PC.insert(p,r); // in the packet cache
@@ -906,6 +907,14 @@ DNSPacket *PacketHandler::questionOrRecurse(DNSPacket *p, bool *shouldRecurse)
     S.inc("servfail-packets");
     S.ringAccount("servfail-queries",p->qdomain);
   }
+  catch(exception &e) {
+    L<<Logger::Error<<"Exception building anser packet ("<<e.what()<<") sending out servfail"<<endl;
+    delete r;
+    r=p->replyPacket();  // generate an empty reply packet    
+    r->setRcode(RCode::ServFail);
+    S.inc("servfail-packets");
+    S.ringAccount("servfail-queries",p->qdomain);
+  }
   return r; 
 
 }