]> granicus.if.org Git - pdns/commitdiff
Handle LuaContext::SyntaxErrorException() in the Console server. Gracefully handle...
authorRemi Gacogne <rgacogne-github@coredump.fr>
Fri, 6 Nov 2015 15:28:56 +0000 (16:28 +0100)
committerRemi Gacogne <rgacogne-github@coredump.fr>
Fri, 6 Nov 2015 15:28:56 +0000 (16:28 +0100)
Fixes #2866.

pdns/dnsdist.cc

index a2f922cf12acfd3f72edc05a82c2e85ad7827e73..8f4488738eaa34acde67995e88010f28a8a9f2bd 100644 (file)
@@ -679,6 +679,9 @@ try
         response += string(e.reason);
       }
     }
+    catch(const LuaContext::SyntaxErrorException& e) {
+      response = "Error: " + string(e.what()) + ": ";
+    }
     response = sodEncryptSym(response, g_key, ours);
     putMsgLen(fd, response.length());
     writen2(fd, response.c_str(), (uint16_t)response.length());
@@ -777,9 +780,13 @@ void doClient(ComboAddress server, const std::string& command)
     uint16_t len;
     getMsgLen(fd, &len);
 
+    if(len == 0) {
+      cout << "Connection closed by the server." << endl;
+      break;
+    }
+
     char resp[len];
-    if(len)
-      readn2(fd, resp, len);
+    readn2(fd, resp, len);
     msg.assign(resp, len);
     msg=sodDecryptSym(msg, g_key, theirs);
     cout<<msg<<endl;