]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
auth: Fix reading invalid iterator in fillZone() 3579/head
authorRemi Gacogne <remi.gacogne@powerdns.com>
Tue, 15 Mar 2016 09:10:59 +0000 (10:10 +0100)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Tue, 15 Mar 2016 09:10:59 +0000 (10:10 +0100)
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

index a3cf2fce028518e9951b16998d002c3a24082f53..07b3015992024161178d444f96bbf59022dc5740 100644 (file)
@@ -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;