do not assume that dns structs are aligned
authorJohannes Wegener <mail@johanneswegener.de>
Wed, 25 Jan 2017 23:07:00 +0000 (00:07 +0100)
committerFelix Fietkau <nbd@nbd.name>
Tue, 31 Jan 2017 10:09:04 +0000 (11:09 +0100)
They do not have a fixed alignment in the packet. ARMv5 has separate
instructions for unaligned and aligned 16-bit load/store. The aligned
ones have undefined behavior if the addresses are unaligned, and that
completely breaks packet parsing.

Signed-off-by: Johannes Wegener <mail@johanneswegener.de>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
dns.h

diff --git a/dns.h b/dns.h
index 791159f..4425d4c 100644 (file)
--- a/dns.h
+++ b/dns.h
@@ -55,19 +55,19 @@ struct dns_srv_data {
        uint16_t priority;
        uint16_t weight;
        uint16_t port;
-} __attribute__((packed, aligned(2)));
+} __attribute__((packed));
 
 struct dns_answer {
        uint16_t type;
        uint16_t class;
        uint32_t ttl;
        uint16_t rdlength;
-} __attribute__((packed, aligned(2)));
+} __attribute__((packed));
 
 struct dns_question {
        uint16_t type;
        uint16_t class;
-} __attribute__((packed, aligned(2)));
+} __attribute__((packed));
 
 struct interface;
 extern int cfg_proto;