Skip to content

Commit

Permalink
Do not access an uint32_t directly, it might be unaligned
Browse files Browse the repository at this point in the history
  • Loading branch information
omoerbeek committed Nov 19, 2024
1 parent 2011fbb commit ea9d3de
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pdns/recursordist/pdns_recursor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Check warning on line 2039 in pdns/recursordist/pdns_recursor.cc

View workflow job for this annotation

GitHub Actions / Analyze (cpp, rec)

variable 'edns' is not initialized (cppcoreguidelines-init-variables - Level=Warning)
memcpy(&edns, &drh->d_ttl, sizeof(edns)); // dh is not neccesarily aligned, so no uint32 assignment
ednsVersion = edns;
}
pos += sizeof(dnsrecordheader);

Expand Down

0 comments on commit ea9d3de

Please sign in to comment.