From: Remi Gacogne Date: Fri, 13 Mar 2020 15:09:51 +0000 (+0100) Subject: auth: Ensure qtype is set before calling setContent() in axfrfilter() X-Git-Tag: rec-4.4.0-beta1~33^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3330ec7952ac061121b7f29d9e94c16a4973cdd7;p=thirdparty%2Fpdns.git auth: Ensure qtype is set before calling setContent() in axfrfilter() Otherwise we might fail to strip a trailing dot for some records. --- diff --git a/pdns/lua-auth4.cc b/pdns/lua-auth4.cc index ede5d1b038..90c527626f 100644 --- a/pdns/lua-auth4.cc +++ b/pdns/lua-auth4.cc @@ -117,21 +117,27 @@ bool AuthLua4::axfrfilter(const ComboAddress& remote, const DNSName& zone, const const auto& rows = std::get<1>(ret); - for(const auto& row: rows) { - DNSResourceRecord rec; - for(const auto& col: row.second) { - if (col.first == "qtype") - rec.qtype = QType(boost::get(col.second)); - else if (col.first == "qname") - rec.qname = DNSName(boost::get(col.second)).makeLowerCase(); - else if (col.first == "ttl") - rec.ttl = boost::get(col.second); - else if (col.first == "content") - rec.setContent(boost::get(col.second)); - else - throw PDNSException("Cannot understand "+col.first+" in axfr filter response on row "+std::to_string(row.first)); + try { + for(const auto& row: rows) { + DNSResourceRecord rec; + + const auto& map = row.second; + rec.qtype = QType(boost::get(map.at("qtype"))); + rec.qname = DNSName(boost::get(map.at("qname"))); + rec.qname.makeUsLowerCase(); + if (map.count("ttl")) { + rec.ttl = boost::get(map.at("ttl")); + } + rec.setContent(boost::get(map.at("content"))); + + out.push_back(rec); } - out.push_back(rec); + } + catch (const std::exception& e) { + throw PDNSException("Cannot understand axfr filter response: " + std::string(e.what())); + } + catch (const PDNSException& e) { + throw PDNSException("Cannot understand axfr filter response: " + e.reason); } return true;