From 904dda47ed67def29a9cfece592637c6777fc54b Mon Sep 17 00:00:00 2001 From: Thomas Bernard Date: Sat, 14 Jan 2023 19:18:37 +0100 Subject: [PATCH] nftnlrdr_misc.c: replace nftnl_rule_get_data() usage with specific nftnl_rule_get_*() functions nftnl_rule_get_u32() nftnl_rule_get_u64() nftnl_rule_get_str() closes #641 should fix #582 --- miniupnpd/netfilter_nft/nftnlrdr_misc.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/miniupnpd/netfilter_nft/nftnlrdr_misc.c b/miniupnpd/netfilter_nft/nftnlrdr_misc.c index 3cbe905..6574611 100644 --- a/miniupnpd/netfilter_nft/nftnlrdr_misc.c +++ b/miniupnpd/netfilter_nft/nftnlrdr_misc.c @@ -545,18 +545,16 @@ table_cb(const struct nlmsghdr *nlh, void *data) result = MNL_CB_ERROR; } else { const char *chain; - uint32_t len; memset(r, 0, sizeof(rule_t)); - chain = (const char *) nftnl_rule_get_data(rule, NFTNL_RULE_CHAIN, &len); + chain = nftnl_rule_get_str(rule, NFTNL_RULE_CHAIN); if (strcmp(chain, nft_prerouting_chain) == 0 || strcmp(chain, nft_postrouting_chain) == 0 || strcmp(chain, nft_forward_chain) == 0) { - r->table = strdup((const char *) nftnl_rule_get_data(rule, NFTNL_RULE_TABLE, &len)); + r->table = strdup(nftnl_rule_get_str(rule, NFTNL_RULE_TABLE)); r->chain = strdup(chain); - r->family = *(uint32_t *) nftnl_rule_get_data(rule, NFTNL_RULE_FAMILY, - &len); + r->family = nftnl_rule_get_u32(rule, NFTNL_RULE_FAMILY); if (nftnl_rule_is_set(rule, NFTNL_RULE_USERDATA)) { const char *descr; descr = (const char *) nftnl_rule_get_data(rule, NFTNL_RULE_USERDATA, @@ -572,9 +570,7 @@ table_cb(const struct nlmsghdr *nlh, void *data) } } - r->handle = *(uint32_t *) nftnl_rule_get_data(rule, - NFTNL_RULE_HANDLE, - &len); + r->handle = nftnl_rule_get_u64(rule, NFTNL_RULE_HANDLE); r->type = CB_DATA(type); itr = nftnl_expr_iter_create(rule);