From: Otto Moerbeek Date: Wed, 6 Apr 2022 09:17:48 +0000 (+0200) Subject: Another case of unaligned access of header data found by ubsan on OpenSBD X-Git-Tag: rec-4.7.0-beta1~11^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=17c011cd73833529e044e88bbddfb912a60cab6e;p=thirdparty%2Fpdns.git Another case of unaligned access of header data found by ubsan on OpenSBD --- diff --git a/pdns/packetcache.hh b/pdns/packetcache.hh index 82f22ffcf1..eba68221f6 100644 --- a/pdns/packetcache.hh +++ b/pdns/packetcache.hh @@ -174,7 +174,8 @@ public: + the OPT RR rdlen (2) = 15 */ - const struct dnsheader* dh = reinterpret_cast(query.data()); + const dnsheader_aligned dnsheaderdata(query.data()); + const struct dnsheader* dh = dnsheaderdata.get(); if (ntohs(dh->qdcount) != 1 || ntohs(dh->ancount) != 0 || ntohs(dh->nscount) != 0 || ntohs(dh->arcount) != 1 || (pos + 15) >= querySize || optionsToIgnore.empty()) { return cachedQuery.compare(pos, cachedQuerySize - pos, query, pos, querySize - pos) == 0; }