diff options
author | Jozsef Kadlecsik <kadlec@blackhole.kfki.hu> | 2015-10-28 17:13:31 +0100 |
---|---|---|
committer | Jozsef Kadlecsik <kadlec@blackhole.kfki.hu> | 2015-10-28 17:13:31 +0100 |
commit | 0516924996e6ce0063ec682bc7b1c01db75af304 (patch) | |
tree | 40377a0c005d13b81230b81be9ac88e49c5be6bc /lib | |
parent | 68afc6a7767d1af4aa5aae89e8dcfc036015c2f3 (diff) |
Handle uint64_t alignment issue in ipset tool
Diffstat (limited to 'lib')
-rw-r--r-- | lib/debug.c | 5 | ||||
-rw-r--r-- | lib/session.c | 5 |
2 files changed, 7 insertions, 3 deletions
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; } |