From: Remi Gacogne Date: Tue, 1 Oct 2019 08:02:14 +0000 (+0200) Subject: dnsdist: Check the address supplied to 'webserver' in check-config X-Git-Tag: dnsdist-1.4.0-rc4~53^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=59b364f3336429ffb4c1f35d1039cde04f5cd899;p=pdns dnsdist: Check the address supplied to 'webserver' in check-config --- diff --git a/pdns/dnsdist-lua.cc b/pdns/dnsdist-lua.cc index 42232d7c5..c362a03fc 100644 --- a/pdns/dnsdist-lua.cc +++ b/pdns/dnsdist-lua.cc @@ -685,9 +685,18 @@ void setupLuaConfig(bool client) g_lua.writeFunction("webserver", [client](const std::string& address, const std::string& password, const boost::optional apiKey, const boost::optional > 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);