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: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F8364%2Fhead;p=thirdparty%2Fpdns.git dnsdist: Check the address supplied to 'webserver' in check-config --- diff --git a/pdns/dnsdist-lua.cc b/pdns/dnsdist-lua.cc index 42232d7c54..c362a03fcf 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);