]> granicus.if.org Git - pdns/commitdiff
dnsdist: Check the address supplied to 'webserver' in check-config
authorRemi Gacogne <remi.gacogne@powerdns.com>
Tue, 1 Oct 2019 08:02:14 +0000 (10:02 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Tue, 1 Oct 2019 08:02:14 +0000 (10:02 +0200)
pdns/dnsdist-lua.cc

index 42232d7c54fa7c2010bfa3f45231d2cdf02a6e78..c362a03fcfad44754c0da114771875182eabaaf0 100644 (file)
@@ -685,9 +685,18 @@ void setupLuaConfig(bool client)
 
   g_lua.writeFunction("webserver", [client](const std::string& address, const std::string& password, const boost::optional<std::string> apiKey, const boost::optional<std::map<std::string, std::string> > customHeaders) {
       setLuaSideEffect();
-      if(client)
-       return;
-      ComboAddress local(address);
+      ComboAddress local;
+      try {
+        local = ComboAddress(address);
+      }
+      catch (const PDNSException& e) {
+        throw std::runtime_error(std::string("Error parsing the bind address for the webserver: ") + e.reason);
+      }
+
+      if (client) {
+        return;
+      }
+
       try {
        int sock = SSocket(local.sin4.sin_family, SOCK_STREAM, 0);
        SSetsockopt(sock, SOL_SOCKET, SO_REUSEADDR, 1);