]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Another case of unaligned access of header data found by ubsan on OpenSBD 11506/head
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Wed, 6 Apr 2022 09:17:48 +0000 (11:17 +0200)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Wed, 6 Apr 2022 09:17:48 +0000 (11:17 +0200)
pdns/packetcache.hh

index 82f22ffcf1bdc29d0e3a8c250010d00ff458e72b..eba68221f64f0bde3f771cd8783026294505e65a 100644 (file)
@@ -174,7 +174,8 @@ public:
        + the OPT RR rdlen (2)
        = 15
     */
-    const struct dnsheader* dh = reinterpret_cast<const struct dnsheader*>(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;
     }