]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Do not access an uint32_t directly, it might be unaligned
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Tue, 19 Nov 2024 13:16:25 +0000 (14:16 +0100)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Tue, 19 Nov 2024 15:03:09 +0000 (16:03 +0100)
pdns/recursordist/pdns_recursor.cc

index ef80d2dbcc9b516926dcfed36baa5b843e2ac64f..24d3541429be7033cacf3cf8b116afbef0f1afd0 100644 (file)
@@ -2036,7 +2036,9 @@ void getQNameAndSubnet(const std::string& question, DNSName* dnsname, uint16_t*
     pos += 1;
     const auto* drh = reinterpret_cast<const dnsrecordheader*>(&question.at(pos)); // NOLINT(cppcoreguidelines-pro-type-reinterpret-cast)
     if (ntohs(drh->d_type) == QType::OPT) {
-      ednsVersion = drh->d_ttl;
+      uint32_t edns{};
+      memcpy(&edns, &drh->d_ttl, sizeof(edns)); // dh is not neccesarily aligned, so no uint32 assignment can be done
+      ednsVersion = edns;
     }
     pos += sizeof(dnsrecordheader);