From 3216c7db1f4311f5cc8aed53b2304e915811d287 Mon Sep 17 00:00:00 2001 From: Peter van Dijk Date: Mon, 21 May 2018 20:09:26 +0200 Subject: [PATCH] move check down --- pdns/ws-auth.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pdns/ws-auth.cc b/pdns/ws-auth.cc index 14a1b5fc81..b63f1bdbcc 100644 --- a/pdns/ws-auth.cc +++ b/pdns/ws-auth.cc @@ -1642,14 +1642,15 @@ static void patchZone(HttpRequest* req, HttpResponse* resp) { apiCheckQNameAllowedCharacters(qname.toString()); QType qtype; qtype = stringFromJson(rrset, "type"); + if (qtype.getCode() == 0) { + throw ApiException("RRset "+qname.toString()+" IN "+stringFromJson(rrset, "type")+": unknown type given"); + } + if(seen.count({qname, qtype})) { - throw ApiException("Duplicate RRset "+qname.toString()+" IN "+stringFromJson(rrset, "type")); + throw ApiException("Duplicate RRset "+qname.toString()+" IN "+qtype.getName()); } seen.insert({qname, qtype}); - if (qtype.getCode() == 0) { - throw ApiException("RRset "+qname.toString()+" IN "+stringFromJson(rrset, "type")+": unknown type given"); - } if (changetype == "DELETE") { // delete all matching qname/qtype RRs (and, implicitly comments). -- 2.47.2