From 17c011cd73833529e044e88bbddfb912a60cab6e Mon Sep 17 00:00:00 2001 From: Otto Moerbeek Date: Wed, 6 Apr 2022 11:17:48 +0200 Subject: [PATCH] Another case of unaligned access of header data found by ubsan on OpenSBD --- pdns/packetcache.hh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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; } -- 2.47.2