From dedd3fc8ed93af8d84ffab9005b29e32e429b4e5 Mon Sep 17 00:00:00 2001 From: Remi Gacogne Date: Tue, 15 Mar 2016 10:10:59 +0100 Subject: [PATCH] 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. ``` --- pdns/ws-auth.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; -- 2.47.2