diff options
author | Pablo Neira Ayuso <pablo@netfilter.org> | 2021-03-17 00:44:09 +0100 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2021-03-24 13:40:37 +0100 |
commit | cd54a9bb2da0686ad3684741f3b8f6696639013f (patch) | |
tree | 3a36473fd395712c97e6f79f3e901d61d50f7c7a /src | |
parent | 47fdff19c0e1aba85cc0edf74fa029d4ed4f10e7 (diff) |
segtree: release single element already contained in an interval
Before this patch:
table ip x {
chain y {
ip saddr { 1.1.1.1-1.1.1.2, 1.1.1.1 }
}
}
results in:
table ip x {
chain y {
ip saddr { 1.1.1.1 }
}
}
due to incorrect interval merge logic.
If the element 1.1.1.1 is already contained in an existing interval
1.1.1.1-1.1.1.2, release it.
Closes: https://bugzilla.netfilter.org/show_bug.cgi?id=1512
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/segtree.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/segtree.c b/src/segtree.c index 9aa39e52..ad199355 100644 --- a/src/segtree.c +++ b/src/segtree.c @@ -210,6 +210,12 @@ static int ei_insert(struct list_head *msgs, struct seg_tree *tree, ei = lei; goto err; } + /* single element contained in an existing interval */ + if (mpz_cmp(new->left, new->right) == 0) { + ei_destroy(new); + goto out; + } + /* * The new interval is entirely contained in the same interval, * split it into two parts: @@ -277,7 +283,7 @@ static int ei_insert(struct list_head *msgs, struct seg_tree *tree, } __ei_insert(tree, new); - +out: mpz_clear(p); return 0; |