From 28e599d1831a517765471d407132acd49c9f3b47 Mon Sep 17 00:00:00 2001 From: Remi Gacogne Date: Wed, 6 Mar 2024 16:46:29 +0100 Subject: [PATCH] dnsdist: Delint dnsdist-xpf.cc --- pdns/dnsdistdist/dnsdist-xpf.cc | 16 ++++++++++------ pdns/dnsdistdist/dnsdist-xpf.hh | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/pdns/dnsdistdist/dnsdist-xpf.cc b/pdns/dnsdistdist/dnsdist-xpf.cc index 305bf0433e..df560ac38d 100644 --- a/pdns/dnsdistdist/dnsdist-xpf.cc +++ b/pdns/dnsdistdist/dnsdist-xpf.cc @@ -26,36 +26,40 @@ #include "dnsparser.hh" #include "xpf.hh" -bool addXPF(DNSQuestion& dq, uint16_t optionCode) +bool addXPF(DNSQuestion& dnsQuestion, uint16_t optionCode) { - std::string payload = generateXPFPayload(dq.overTCP(), dq.ids.origRemote, dq.ids.origDest); + std::string payload = generateXPFPayload(dnsQuestion.overTCP(), dnsQuestion.ids.origRemote, dnsQuestion.ids.origDest); uint8_t root = '\0'; - dnsrecordheader drh; + dnsrecordheader drh{}; drh.d_type = htons(optionCode); drh.d_class = htons(QClass::IN); drh.d_ttl = 0; drh.d_clen = htons(payload.size()); size_t recordHeaderLen = sizeof(root) + sizeof(drh); - if (!dq.hasRoomFor(payload.size() + recordHeaderLen)) { + if (!dnsQuestion.hasRoomFor(payload.size() + recordHeaderLen)) { return false; } size_t xpfSize = sizeof(root) + sizeof(drh) + payload.size(); - auto& data = dq.getMutableData(); + auto& data = dnsQuestion.getMutableData(); + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast) uint32_t realPacketLen = getDNSPacketLength(reinterpret_cast(data.data()), data.size()); data.resize(realPacketLen + xpfSize); size_t pos = realPacketLen; + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast) memcpy(reinterpret_cast(&data.at(pos)), &root, sizeof(root)); pos += sizeof(root); + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast) memcpy(reinterpret_cast(&data.at(pos)), &drh, sizeof(drh)); pos += sizeof(drh); + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast) memcpy(reinterpret_cast(&data.at(pos)), payload.data(), payload.size()); pos += payload.size(); (void)pos; - dnsdist::PacketMangling::editDNSHeaderFromPacket(dq.getMutableData(), [](dnsheader& header) { + dnsdist::PacketMangling::editDNSHeaderFromPacket(dnsQuestion.getMutableData(), [](dnsheader& header) { header.arcount = htons(ntohs(header.arcount) + 1); return true; }); diff --git a/pdns/dnsdistdist/dnsdist-xpf.hh b/pdns/dnsdistdist/dnsdist-xpf.hh index 30de2234c0..a3de71029e 100644 --- a/pdns/dnsdistdist/dnsdist-xpf.hh +++ b/pdns/dnsdistdist/dnsdist-xpf.hh @@ -23,4 +23,4 @@ #include "dnsdist.hh" -bool addXPF(DNSQuestion& dq, uint16_t optionCode); +bool addXPF(DNSQuestion& dnsQuestion, uint16_t optionCode); -- 2.47.3