]> granicus.if.org Git - pdns/commitdiff
rec: Prevent an exception in RCC handling from terminating the rec
authorRemi Gacogne <remi.gacogne@powerdns.com>
Tue, 19 Mar 2019 15:29:10 +0000 (16:29 +0100)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Tue, 19 Mar 2019 15:29:10 +0000 (16:29 +0100)
pdns/pdns_recursor.cc

index 8715b3ba87cac8a4dc03b3e1dc4405dbd2e1d0de..b8d1f8ade5e1a98c9c62ff27bfa7abbdd4aafe38 100644 (file)
@@ -2979,27 +2979,27 @@ template vector<pair<DNSName,uint16_t> > broadcastAccFunction(const boost::funct
 
 static void handleRCC(int fd, FDMultiplexer::funcparam_t& var)
 {
-  string remote;
-  string msg=s_rcc.recv(&remote);
-  RecursorControlParser rcp;
-  RecursorControlParser::func_t* command;
+  try {
+    string remote;
+    string msg=s_rcc.recv(&remote);
+    RecursorControlParser rcp;
+    RecursorControlParser::func_t* command;
 
-  string answer=rcp.getAnswer(msg, &command);
+    string answer=rcp.getAnswer(msg, &command);
 
-  // If we are inside a chroot, we need to strip
-  if (!arg()["chroot"].empty()) {
-    size_t len = arg()["chroot"].length();
-    remote = remote.substr(len);
-  }
+    // If we are inside a chroot, we need to strip
+    if (!arg()["chroot"].empty()) {
+      size_t len = arg()["chroot"].length();
+      remote = remote.substr(len);
+    }
 
-  try {
     s_rcc.send(answer, &remote);
     command();
   }
-  catch(std::exception& e) {
+  catch(const std::exception& e) {
     g_log<<Logger::Error<<"Error dealing with control socket request: "<<e.what()<<endl;
   }
-  catch(PDNSException& ae) {
+  catch(const PDNSException& ae) {
     g_log<<Logger::Error<<"Error dealing with control socket request: "<<ae.reason<<endl;
   }
 }