From: Remi Gacogne Date: Tue, 15 Mar 2016 09:10:59 +0000 (+0100) Subject: auth: Fix reading invalid iterator in fillZone() X-Git-Tag: dnsdist-1.0.0-beta1~93^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F3579%2Fhead;p=thirdparty%2Fpdns.git auth: Fix reading invalid iterator in fillZone() Reported by coverity: ``` CID 1353069 (#1 of 1): Using invalid iterator (INVALIDATE_ITERATOR) 19. deref_iterator: Dereferencing iterator rit though it is already past the end of its container. ``` --- diff --git a/pdns/ws-auth.cc b/pdns/ws-auth.cc index a3cf2fce02..07b3015992 100644 --- a/pdns/ws-auth.cc +++ b/pdns/ws-auth.cc @@ -381,7 +381,7 @@ static void fillZone(const DNSName& zonename, HttpResponse* resp) { auto cit = comments.begin(); while (rit != records.end() || cit != comments.end()) { - if (cit == comments.end() || cit->qname.toString() < rit->qname.toString() || cit->qtype < rit->qtype) { + if (cit == comments.end() || (rit != records.end() && (cit->qname.toString() < rit->qname.toString() || cit->qtype < rit->qtype))) { current_qname = rit->qname; current_qtype = rit->qtype; ttl = rit->ttl;