From 59b364f3336429ffb4c1f35d1039cde04f5cd899 Mon Sep 17 00:00:00 2001 From: Remi Gacogne Date: Tue, 1 Oct 2019 10:02:14 +0200 Subject: [PATCH] dnsdist: Check the address supplied to 'webserver' in check-config --- pdns/dnsdist-lua.cc | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) 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); -- 2.47.2