From: Peter van Dijk Date: Tue, 3 Jun 2025 11:52:21 +0000 (+0200) Subject: auth views http: report network typos to user X-Git-Tag: dnsdist-2.0.0-beta1~24^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=71240ecbce55111cebc3fb275a9083061a482dfe;p=thirdparty%2Fpdns.git auth views http: report network typos to user --- diff --git a/pdns/ws-auth.cc b/pdns/ws-auth.cc index 0463cb8a96..5658ae4562 100644 --- a/pdns/ws-auth.cc +++ b/pdns/ws-auth.cc @@ -20,6 +20,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include "dnsbackend.hh" +#include "iputils.hh" #include "webserver.hh" #include #include @@ -2760,7 +2761,12 @@ static void apiServerNetworksGET(HttpRequest* req, HttpResponse* resp) if (req->parameters.count("ip") != 0 && req->parameters.count("prefixlen") != 0) { std::string subnet{req->parameters["ip"]}; std::string prefixlen{req->parameters["prefixlen"]}; - network = subnet + "/" + prefixlen; + try { + network = subnet + "/" + prefixlen; + } + catch (NetmaskException& e) { + throw ApiException(e.reason); + } } UeberBackend backend; @@ -2792,7 +2798,13 @@ static void apiServerNetworksPUT(HttpRequest* req, HttpResponse* resp) { std::string subnet{req->parameters["ip"]}; std::string prefixlen{req->parameters["prefixlen"]}; - Netmask network(subnet + "/" + prefixlen); + Netmask network; + try { + network = subnet + "/" + prefixlen; + } + catch (NetmaskException& e) { + throw ApiException(e.reason); + } const auto& document = req->json(); std::string view = stringFromJson(document, "view");