]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Properly handle truncation for UDP responses sent via `sendmmsg` 16081/head
authorRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 1 Sep 2025 12:00:09 +0000 (14:00 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Thu, 4 Sep 2025 15:13:59 +0000 (17:13 +0200)
Signed-off-by: Remi Gacogne <remi.gacogne@powerdns.com>
(cherry picked from commit bf06a3d6b2f517b0cf365e218c752548029ea4a6)

pdns/dnsdistdist/dnsdist.cc

index 0977b45cabe311cb20c74c6c1873d84cfa446469..6c0cc94beb9d1e03bd71be86146378dbb6d4fb95 100644 (file)
@@ -1898,6 +1898,8 @@ static void processUDPQuery(ClientState& clientState, const struct msghdr* msgh,
     // the buffer might have been invalidated by now (resized)
     const auto dnsHeader = dnsQuestion.getHeader();
     if (result == ProcessQueryResult::SendAnswer) {
+      /* ensure payload size is not exceeded */
+      handleResponseTC4UDPClient(dnsQuestion, udpPayloadSize, query);
 #ifndef DISABLE_RECVMMSG
 #if defined(HAVE_RECVMMSG) && defined(HAVE_SENDMMSG) && defined(MSG_WAITFORONE)
       if (dnsQuestion.ids.delayMsec == 0 && responsesVect != nullptr) {
@@ -1908,8 +1910,6 @@ static void processUDPQuery(ClientState& clientState, const struct msghdr* msgh,
       }
 #endif /* defined(HAVE_RECVMMSG) && defined(HAVE_SENDMMSG) && defined(MSG_WAITFORONE) */
 #endif /* DISABLE_RECVMMSG */
-      /* ensure payload size is not exceeded */
-      handleResponseTC4UDPClient(dnsQuestion, udpPayloadSize, query);
       /* we use dest, always, because we don't want to use the listening address to send a response since it could be 0.0.0.0 */
       sendUDPResponse(clientState.udpFD, query, dnsQuestion.ids.delayMsec, dest, remote);