summaryrefslogtreecommitdiff
path: root/pkt.h
diff options
context:
space:
mode:
authorMichael Evertz <Michael.Evertz@devolo.de>2016-09-12 14:37:53 +0200
committerTobias Klauser <tklauser@distanz.ch>2016-09-12 16:55:14 +0200
commit9bec6fb916f65cec99e981a6733984a8a17f30d3 (patch)
treed321b768345fb135b6ed0e35bc292d53f160bacc /pkt.h
parentd4ae5d9bb723e2ec2fcbaaa954cb76312bca1e7a (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 'pkt.h')
-rw-r--r--pkt.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/pkt.h b/pkt.h
index e829b8c..bb2b717 100644
--- a/pkt.h
+++ b/pkt.h
@@ -100,8 +100,8 @@ static inline uint8_t *pkt_put(struct pkt *p, size_t len)
#define DEFINE_PKT_PUT(__bitwidth) \
static inline void pkt_put_u##__bitwidth(struct pkt *p, uint##__bitwidth##_t val) \
{ \
- uint##__bitwidth##_t *data = (uint##__bitwidth##_t *)pkt_put(p, sizeof(val)); \
- *data = val; \
+ uint8_t *data = pkt_put(p, sizeof(val)); \
+ memcpy(data, &val, sizeof(uint##__bitwidth##_t)); \
}
DEFINE_PKT_PUT(8)