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/osf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/expr/osf.c') diff --git a/src/expr/osf.c b/src/expr/osf.c index a90620d..0860328 100644 --- a/src/expr/osf.c +++ b/src/expr/osf.c @@ -24,10 +24,10 @@ static int nftnl_expr_osf_set(struct nftnl_expr *e, uint16_t type, switch(type) { case NFTNL_EXPR_OSF_DREG: - osf->dreg = *((uint32_t *)data); + memcpy(&osf->dreg, data, sizeof(osf->dreg)); break; case NFTNL_EXPR_OSF_TTL: - osf->ttl = *((uint8_t *)data); + memcpy(&osf->ttl, data, sizeof(osf->ttl)); break; } return 0; -- cgit v1.2.3