Commit 02f815cb authored by Jozsef Kadlecsik's avatar Jozsef Kadlecsik Committed by Pablo Neira Ayuso

netfilter: ipset: list:set: fix reference counter update

The last element can be replaced or pushed off and in both
cases the reference counter must be updated.
Signed-off-by: default avatarJozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
parent 3a7b21ea
...@@ -174,9 +174,13 @@ list_set_add(struct list_set *map, u32 i, ip_set_id_t id, ...@@ -174,9 +174,13 @@ list_set_add(struct list_set *map, u32 i, ip_set_id_t id,
{ {
const struct set_elem *e = list_set_elem(map, i); const struct set_elem *e = list_set_elem(map, i);
if (i == map->size - 1 && e->id != IPSET_INVALID_ID) if (e->id != IPSET_INVALID_ID) {
/* Last element replaced: e.g. add new,before,last */ const struct set_elem *x = list_set_elem(map, map->size - 1);
ip_set_put_byindex(e->id);
/* Last element replaced or pushed off */
if (x->id != IPSET_INVALID_ID)
ip_set_put_byindex(x->id);
}
if (with_timeout(map->timeout)) if (with_timeout(map->timeout))
list_elem_tadd(map, i, id, ip_set_timeout_set(timeout)); list_elem_tadd(map, i, id, ip_set_timeout_set(timeout));
else else
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment