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/table.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/table.c') diff --git a/src/table.c b/src/table.c index c987c5e..54259ee 100644 --- a/src/table.c +++ b/src/table.c @@ -101,16 +101,16 @@ int nftnl_table_set_data(struct nftnl_table *t, uint16_t attr, return -1; break; case NFTNL_TABLE_HANDLE: - t->handle = *((uint64_t *)data); + memcpy(&t->handle, data, sizeof(t->handle)); break; case NFTNL_TABLE_FLAGS: - t->table_flags = *((uint32_t *)data); + memcpy(&t->table_flags, data, sizeof(t->table_flags)); break; case NFTNL_TABLE_FAMILY: - t->family = *((uint32_t *)data); + memcpy(&t->family, data, sizeof(t->family)); break; case NFTNL_TABLE_USE: - t->use = *((uint32_t *)data); + memcpy(&t->use, data, sizeof(t->use)); break; } t->flags |= (1 << attr); -- cgit v1.2.3