From: Otto Moerbeek Date: Tue, 19 Nov 2024 13:16:25 +0000 (+0100) Subject: Do not access an uint32_t directly, it might be unaligned X-Git-Tag: rec-5.2.0-beta1~4^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ce932a759e3699502c2c05070a2d5fd2af0212da;p=thirdparty%2Fpdns.git Do not access an uint32_t directly, it might be unaligned --- diff --git a/pdns/recursordist/pdns_recursor.cc b/pdns/recursordist/pdns_recursor.cc index ef80d2dbcc..24d3541429 100644 --- a/pdns/recursordist/pdns_recursor.cc +++ b/pdns/recursordist/pdns_recursor.cc @@ -2036,7 +2036,9 @@ void getQNameAndSubnet(const std::string& question, DNSName* dnsname, uint16_t* pos += 1; const auto* drh = reinterpret_cast(&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);