diff options
author | Phil Sutter <phil@nwl.cc> | 2018-08-02 17:05:20 +0200 |
---|---|---|
committer | Florian Westphal <fw@strlen.de> | 2018-08-04 14:48:08 +0200 |
commit | 2e478e90d3a0ec00b6702732f3a80328c6a4012d (patch) | |
tree | 3a0ab46d68416c76b5fdda81bd3f8ee90df54877 /iptables/xtables-eb.c | |
parent | a192f03520ebd0a2c0ecfca8abd1e00967f3b351 (diff) |
ebtables: Fix match_list insertion
Find the end of the match_list before inserting in case the list
contains more than one element.
Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Florian Westphal <fw@strlen.de>
Diffstat (limited to 'iptables/xtables-eb.c')
-rw-r--r-- | iptables/xtables-eb.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/iptables/xtables-eb.c b/iptables/xtables-eb.c index a88655ce..e6a17a00 100644 --- a/iptables/xtables-eb.c +++ b/iptables/xtables-eb.c @@ -675,7 +675,7 @@ void ebt_add_match(struct xtables_match *m, { struct xtables_rule_match *i, **rule_matches = &cs->matches; struct xtables_match *newm; - struct ebt_match *newnode; + struct ebt_match *newnode, **matchp; /* match already in rule_matches, skip inclusion */ for (i = *rule_matches; i; i = i->next) { @@ -700,16 +700,15 @@ void ebt_add_match(struct xtables_match *m, newnode->ismatch = true; newnode->u.match = newm; - if (cs->match_list == NULL) - cs->match_list = newnode; - else - cs->match_list->next = newnode; + for (matchp = &cs->match_list; *matchp; matchp = &(*matchp)->next) + ; + *matchp = newnode; } void ebt_add_watcher(struct xtables_target *watcher, struct iptables_command_state *cs) { - struct ebt_match *i, *newnode; + struct ebt_match *i, *newnode, **matchp; for (i = cs->match_list; i; i = i->next) { if (i->ismatch) @@ -726,10 +725,9 @@ void ebt_add_watcher(struct xtables_target *watcher, newnode->u.watcher = watcher; - if (cs->match_list == NULL) - cs->match_list = newnode; - else - cs->match_list->next = newnode; + for (matchp = &cs->match_list; *matchp; matchp = &(*matchp)->next) + ; + *matchp = newnode; } int nft_init_eb(struct nft_handle *h, const char *pname) |