]> granicus.if.org Git - pdns/commitdiff
avoid concurrent records/comments iteration from running out of sync
authorPeter van Dijk <peter.van.dijk@powerdns.com>
Fri, 6 Jul 2018 16:47:00 +0000 (18:47 +0200)
committerPeter van Dijk <peter.van.dijk@powerdns.com>
Thu, 12 Jul 2018 07:32:48 +0000 (09:32 +0200)
(cherry picked from commit 5481c77c8917ef3097d37e0da8a450a01b09f3de)

pdns/ws-auth.cc

index 61bd9e2570eeca262c6eada70c0b6aab67eee986..98733f2ad79db4abf6718af8aebcc676a5a7ff57 100644 (file)
@@ -402,7 +402,8 @@ static void fillZone(const DNSName& zonename, HttpResponse* resp, bool doRRSets)
     auto cit = comments.begin();
 
     while (rit != records.end() || cit != comments.end()) {
-      if (cit == comments.end() || (rit != records.end() && (cit->qname.toString() <= rit->qname.toString() || cit->qtype < rit->qtype || cit->qtype == rit->qtype))) {
+      // if you think this should be rit < cit instead of cit < rit, note the b < a instead of a < b in the sort comparison functions above
+      if (cit == comments.end() || (rit != records.end() && (rit->qname == cit->qname ? (cit->qtype < rit->qtype || cit->qtype == rit->qtype) : cit->qname < rit->qname))) {
         current_qname = rit->qname;
         current_qtype = rit->qtype;
         ttl = rit->ttl;