]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Properly zero-initialize the "fake" DNS header
authorRemi Gacogne <remi.gacogne@powerdns.com>
Fri, 10 Oct 2025 14:39:56 +0000 (16:39 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 20 Oct 2025 09:08:01 +0000 (11:08 +0200)
Signed-off-by: Remi Gacogne <remi.gacogne@powerdns.com>
(cherry picked from commit 153a1bf296f58c38cfd4fb96de29e2677ac42e04)

pdns/dnsdistdist/dnsdist.cc

index e595d4ee38e7a8f210054c02843aad760acb810e..40506e4a149581e279d30bb5df29bf5f0362ebe3 100644 (file)
@@ -1593,9 +1593,11 @@ bool handleTimeoutResponseRules(const std::vector<dnsdist::rules::ResponseRuleAc
   /* let's be nice and restore the original DNS header as well as we can with what we have */
   PacketBuffer payload(sizeof(dnsheader));
   dnsdist::PacketMangling::editDNSHeaderFromPacket(payload, [&ids](dnsheader& header) {
+    memset(&header, 0, sizeof(header));
     header.id = ids.origID;
-    header.qdcount = htons(1);
     restoreFlags(&header, ids.origFlags);
+    // do not set the qdcount, otherwise the protobuf code will choke on it
+    // while trying to parse the response RRs
     return true;
   });
   DNSResponse dnsResponse(ids, payload, d_ds);