]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Proper error handling in setEDNSOption 17394/head
authorRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 18 May 2026 10:42:33 +0000 (12:42 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 18 May 2026 10:42:33 +0000 (12:42 +0200)
We need to return false when it was not possible to set the option,
and to properly set the value indicating that we added an EDNS OPT
RR if needed.

Signed-off-by: Remi Gacogne <remi.gacogne@powerdns.com>
pdns/dnsdistdist/dnsdist-ecs.cc

index c1977ae31c46fa7405d548949f93b8e81a1ce7a4..92dc3b612fa6586102a472091770d0aea43d762a 100644 (file)
@@ -1153,13 +1153,16 @@ bool setEDNSOption(PacketBuffer& buf, uint16_t ednsCode, const std::string& edns
     return true;
   }
 
-  if (generateOptRR(optRData, buf, maximumSize, dnsdist::configuration::s_EdnsUDPPayloadSize, 0, false)) {
-    dnsdist::PacketMangling::editDNSHeaderFromPacket(buf, [](dnsheader& header) {
-      header.arcount = htons(1);
-      return true;
-    });
+  if (!generateOptRR(optRData, buf, maximumSize, dnsdist::configuration::s_EdnsUDPPayloadSize, 0, false)) {
+    return false;
   }
 
+  dnsdist::PacketMangling::editDNSHeaderFromPacket(buf, [](dnsheader& header) {
+    header.arcount = htons(1);
+    return true;
+  });
+  ednsAdded = true;
+
   return true;
 }