diff options
author | Phil Sutter <phil@nwl.cc> | 2019-01-22 11:14:21 +0100 |
---|---|---|
committer | Florian Westphal <fw@strlen.de> | 2019-02-01 15:49:29 +0100 |
commit | 432a5ecfa7890bd3495bb1ab5e34c2258090133f (patch) | |
tree | 7ff1c924a4a1e30ca0d5cc3f843c9a3975250ad4 /iptables/nft-bridge.c | |
parent | 32ebc39f71e8107d6069a9f6fba8338a2823889d (diff) |
nft: Fix potential memleaks in nft_*_rule_find()
These functions parse an nftnl_rule into a local instance of
iptables_command_state which potentially allocates memory (for matches
or target), so call ops->clear_cs() before returning to caller.
Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Florian Westphal <fw@strlen.de>
Diffstat (limited to 'iptables/nft-bridge.c')
-rw-r--r-- | iptables/nft-bridge.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/iptables/nft-bridge.c b/iptables/nft-bridge.c index 61c82f72..b4265c8a 100644 --- a/iptables/nft-bridge.c +++ b/iptables/nft-bridge.c @@ -548,30 +548,34 @@ static bool nft_bridge_rule_find(struct nft_family_ops *ops, struct nftnl_rule * { struct iptables_command_state *cs = data; struct iptables_command_state this = {}; + bool ret = false; nft_rule_to_ebtables_command_state(r, &this); DEBUGP("comparing with... "); if (!nft_bridge_is_same(cs, &this)) - return false; + goto out; if (!compare_matches(cs->matches, this.matches)) { DEBUGP("Different matches\n"); - return false; + goto out; } if (!compare_targets(cs->target, this.target)) { DEBUGP("Different target\n"); - return false; + goto out; } if (cs->jumpto != NULL && strcmp(cs->jumpto, this.jumpto) != 0) { DEBUGP("Different verdict\n"); - return false; + goto out; } - return true; + ret = true; +out: + ops->clear_cs(&this); + return ret; } static int xlate_ebmatches(const struct iptables_command_state *cs, struct xt_xlate *xl) |