From 71240ecbce55111cebc3fb275a9083061a482dfe Mon Sep 17 00:00:00 2001 From: Peter van Dijk Date: Tue, 3 Jun 2025 13:52:21 +0200 Subject: [PATCH] auth views http: report network typos to user --- pdns/ws-auth.cc | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) 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"); -- 2.47.2