From 0516924996e6ce0063ec682bc7b1c01db75af304 Mon Sep 17 00:00:00 2001 From: Jozsef Kadlecsik Date: Wed, 28 Oct 2015 17:13:31 +0100 Subject: Handle uint64_t alignment issue in ipset tool --- lib/debug.c | 5 +++-- lib/session.c | 5 ++++- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/debug.c b/lib/debug.c index b2c5003..6f831ec 100644 --- a/lib/debug.c +++ b/lib/debug.c @@ -77,6 +77,7 @@ debug_cadt_attrs(int max, const struct ipset_attr_policy *policy, const struct ipset_attrname attr2name[], struct nlattr *nla[]) { + uint64_t tmp; uint32_t v; int i; @@ -102,10 +103,10 @@ debug_cadt_attrs(int max, const struct ipset_attr_policy *policy, attr2name[i].name, ntohl(v)); break; case MNL_TYPE_U64: + memcpy(&tmp, mnl_attr_get_payload(nla[i]), sizeof(tmp)); fprintf(stderr, "\t\t%s: 0x%llx\n", attr2name[i].name, (long long int) - be64toh(*(uint64_t *) - mnl_attr_get_payload(nla[i]))); + be64toh(tmp)); break; case MNL_TYPE_NUL_STRING: fprintf(stderr, "\t\t%s: %s\n", diff --git a/lib/session.c b/lib/session.c index 95c253e..24f29f5 100644 --- a/lib/session.c +++ b/lib/session.c @@ -636,7 +636,10 @@ attr2data(struct ipset_session *session, struct nlattr *nla[], D("netorder attr type %u", type); switch (attr->type) { case MNL_TYPE_U64: { - v64 = be64toh(*(const uint64_t *)d); + uint64_t tmp; + /* Ensure data alignment */ + memcpy(&tmp, d, sizeof(tmp)); + v64 = be64toh(tmp); d = &v64; break; } -- cgit v1.2.3