MT#57371 use non-local storage for nft target info

Setting the target info of an `expr` object doesn't result on the data
being copied by libnftnl (unlike other objects). Use static storage to
fix invalid pointer usage.

Reported in #984
Closes #1731

Change-Id: Ic5c156a83504a24fb618d770ba53cd1ec4fb2435
pull/1747/head
Richard Fuchs 2 years ago
parent ea6cc29e83
commit 804df63f74

@ -59,6 +59,9 @@ struct add_rule_callbacks {
const char *chain;
const char *base_chain;
int table;
// intermediate storage area
struct xt_rtpengine_info rtpe_target_info;
};
@ -337,7 +340,6 @@ static const char *add_rule(struct mnl_socket *nl, int family, uint32_t *seq,
return batch_request("add rule", nl, family, seq, NFT_MSG_NEWRULE, NLM_F_APPEND | NLM_F_CREATE,
nftnl_rule_nlmsg_build_payload, r);
}
@ -405,9 +407,9 @@ static const char *rtpe_target(struct nftnl_rule *r, int family, struct add_rule
nftnl_expr_set_str(e, NFTNL_EXPR_TG_NAME, "RTPENGINE");
nftnl_expr_set_u32(e, NFTNL_EXPR_TG_REV, 0);
struct xt_rtpengine_info info = { .id = callbacks->table };
callbacks->rtpe_target_info = (struct xt_rtpengine_info) { .id = callbacks->table };
nftnl_expr_set(e, NFTNL_EXPR_TG_INFO, &info, sizeof(info));
nftnl_expr_set(e, NFTNL_EXPR_TG_INFO, &callbacks->rtpe_target_info, sizeof(callbacks->rtpe_target_info));
nftnl_rule_add_expr(r, e);
e = NULL;

Loading…
Cancel
Save