From dc240913458d591f59b52b3899d3fc3c5d6ec6ce Mon Sep 17 00:00:00 2001 From: Matt Turner Date: Wed, 17 Oct 2018 12:32:54 -0700 Subject: src: Use memcpy() to handle potentially unaligned data Rolf Eike Beer reported that nft-expr_quota-test fails with a SIGBUS on SPARC due to unaligned accesses. This patch resolves that and fixes additional sources of unaligned accesses matching the same pattern. Both nft-expr_quota-test and nft-expr_objref-test generated unaligned accesses on DEC Alpha. Bug: https://bugs.gentoo.org/666448 Signed-off-by: Matt Turner Signed-off-by: Pablo Neira Ayuso --- src/expr/limit.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/expr/limit.c') diff --git a/src/expr/limit.c b/src/expr/limit.c index 4831abd..2a0adba 100644 --- a/src/expr/limit.c +++ b/src/expr/limit.c @@ -38,19 +38,19 @@ nftnl_expr_limit_set(struct nftnl_expr *e, uint16_t type, switch(type) { case NFTNL_EXPR_LIMIT_RATE: - limit->rate = *((uint64_t *)data); + memcpy(&limit->rate, data, sizeof(limit->rate)); break; case NFTNL_EXPR_LIMIT_UNIT: - limit->unit = *((uint64_t *)data); + memcpy(&limit->unit, data, sizeof(limit->unit)); break; case NFTNL_EXPR_LIMIT_BURST: - limit->burst = *((uint32_t *)data); + memcpy(&limit->burst, data, sizeof(limit->burst)); break; case NFTNL_EXPR_LIMIT_TYPE: - limit->type = *((uint32_t *)data); + memcpy(&limit->type, data, sizeof(limit->type)); break; case NFTNL_EXPR_LIMIT_FLAGS: - limit->flags = *((uint32_t *)data); + memcpy(&limit->flags, data, sizeof(limit->flags)); break; default: return -1; -- cgit v1.2.3