diff options
author | Michael Evertz <Michael.Evertz@devolo.de> | 2016-09-12 14:37:53 +0200 |
---|---|---|
committer | Tobias Klauser <tklauser@distanz.ch> | 2016-09-12 16:55:14 +0200 |
commit | 9bec6fb916f65cec99e981a6733984a8a17f30d3 (patch) | |
tree | d321b768345fb135b6ed0e35bc292d53f160bacc /llmnr.c | |
parent | d4ae5d9bb723e2ec2fcbaaa954cb76312bca1e7a (diff) |
Fix misaligned memory access
This changes fixes misaligned memory access. Without the patch I get
several "Misaligend access trap for user program 'llmnrd'" messages on
my platform if the system has odd hostname length.
Diffstat (limited to 'llmnr.c')
-rw-r--r-- | llmnr.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -124,8 +124,10 @@ static void llmnr_respond(unsigned int ifindex, const struct llmnr_hdr *hdr, if ((query_len - name_len - 2) < (sizeof(qtype) + sizeof(qclass))) return; - qtype = ntohs(*((uint16_t *)query_name_end)); - qclass = ntohs(*((uint16_t *)query_name_end + 1)); + memcpy(&qtype, query_name_end, sizeof(qtype)); + qtype = ntohs(qtype); + memcpy(&qclass, query_name_end + sizeof(qtype), sizeof(qclass)); + qclass = ntohs(qclass); /* Only IN queries supported */ if (qclass != LLMNR_QCLASS_IN) |