dns: explicitly endian-convert all fields in header and question
authorPaul Fertser <fercerpav@gmail.com>
Sat, 4 Apr 2020 10:25:14 +0000 (13:25 +0300)
committerKevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
Sat, 4 Apr 2020 19:21:51 +0000 (20:21 +0100)
commit45c4953b602962ae7ff335d9a346000f00680952
treee2de2fa733470d2bea9587bc7d3b6c1093337fac
parent78974417e182a3de8f78b7d73366ec0c98396b6c
dns: explicitly endian-convert all fields in header and question

For added type-safety and to avoid possible alignment issues make all
conversions explicit. While at it, mark header struct as packed so that
its layout is guaranteed to match RFC.

Prompted by gcc 8 & 9 warning in dns.c:

dns.c:261:2: error: converting a packed ‘struct dns_question’
pointer (alignment 1) to a ‘uint16_t’ {aka ‘short unsigned int’} pointer
(alignment 2) may result in an unaligned pointer value
[-Werror=address-of-packed-member]

261 |  uint16_t *swap = (uint16_t *) q;

Signed-off-by: Paul Fertser <fercerpav@gmail.com>
[Tweak commit message]
Acked-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
dns.c
dns.h