diff options
author | Pablo Neira Ayuso <pablo@netfilter.org> | 2021-06-19 01:42:20 +0200 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2021-06-23 13:30:21 +0200 |
commit | fea6a0a60c8cd6ba49cf3b85b4ad08a9028a1bab (patch) | |
tree | 825bae60e166a1a2fa53bc51e3159391c462aa58 | |
parent | dd084d6bfc32ce492084bed9d5e90aeef171503a (diff) |
libnftables: fix memleak when first message in batch is used to report error
The err->seqnum == batch_seqnum case results in a memleak of mnl_err
objects under some scenarios such as nf_tables kernel support is not
available or user runs the nft executable as non-root.
Fixes: f930cc500318 ("nftables: fix supression of "permission denied" errors")
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
-rw-r--r-- | src/libnftables.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/libnftables.c b/src/libnftables.c index e080eb03..e3b6ff0a 100644 --- a/src/libnftables.c +++ b/src/libnftables.c @@ -89,6 +89,12 @@ static int nft_netlink(struct nft_ctx *nft, last_seqnum = UINT32_MAX; } } + /* nfnetlink uses the first netlink message header in the batch whose + * sequence number is zero to report for EOPNOTSUPP and EPERM errors in + * some scenarios. Now it is safe to release pending errors here. + */ + list_for_each_entry_safe(err, tmp, &err_list, head) + mnl_err_list_free(err); out: mnl_batch_reset(ctx.batch); return ret; |