summaryrefslogtreecommitdiffstats
path: root/src/expr/exthdr.c
diff options
context:
space:
mode:
authorMatt Turner <mattst88@gmail.com>2018-10-17 12:32:54 -0700
committerPablo Neira Ayuso <pablo@netfilter.org>2018-10-19 14:56:08 +0200
commitdc240913458d591f59b52b3899d3fc3c5d6ec6ce (patch)
treeb43acfe0306f2ab42a5f5abccc42420fe6a5508c /src/expr/exthdr.c
parentaecc936180d302947ecfab5dacf267a701a5d84c (diff)
src: Use memcpy() to handle potentially unaligned data
Rolf Eike Beer <eike@sf-mail.de> 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 <mattst88@gmail.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/expr/exthdr.c')
-rw-r--r--src/expr/exthdr.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/expr/exthdr.c b/src/expr/exthdr.c
index ec6a855..0e09814 100644
--- a/src/expr/exthdr.c
+++ b/src/expr/exthdr.c
@@ -46,25 +46,25 @@ nftnl_expr_exthdr_set(struct nftnl_expr *e, uint16_t type,
switch(type) {
case NFTNL_EXPR_EXTHDR_DREG:
- exthdr->dreg = *((uint32_t *)data);
+ memcpy(&exthdr->dreg, data, sizeof(exthdr->dreg));
break;
case NFTNL_EXPR_EXTHDR_TYPE:
- exthdr->type = *((uint8_t *)data);
+ memcpy(&exthdr->type, data, sizeof(exthdr->type));
break;
case NFTNL_EXPR_EXTHDR_OFFSET:
- exthdr->offset = *((uint32_t *)data);
+ memcpy(&exthdr->offset, data, sizeof(exthdr->offset));
break;
case NFTNL_EXPR_EXTHDR_LEN:
- exthdr->len = *((uint32_t *)data);
+ memcpy(&exthdr->len, data, sizeof(exthdr->len));
break;
case NFTNL_EXPR_EXTHDR_OP:
- exthdr->op = *((uint32_t *)data);
+ memcpy(&exthdr->op, data, sizeof(exthdr->op));
break;
case NFTNL_EXPR_EXTHDR_FLAGS:
- exthdr->flags = *((uint32_t *)data);
+ memcpy(&exthdr->flags, data, sizeof(exthdr->flags));
break;
case NFTNL_EXPR_EXTHDR_SREG:
- exthdr->sreg = *((uint32_t *)data);
+ memcpy(&exthdr->sreg, data, sizeof(exthdr->sreg));
break;
default:
return -1;