]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
segtree: Fix expr_value_cmp()
authorPhil Sutter <phil@nwl.cc>
Thu, 6 Jul 2017 14:25:28 +0000 (16:25 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Mon, 17 Jul 2017 15:28:46 +0000 (17:28 +0200)
Instead of returning the result of mpz_cmp(), this function returned 1
unless both elements were equal and the first one had
EXPR_F_INTERVAL_END set.

Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/segtree.c

index a2316a7b9804141c17eaabc4f68ea67ac8381a5b..f53536210018d082d0213a11d00d4ffee55e7364 100644 (file)
@@ -602,10 +602,12 @@ static int expr_value_cmp(const void *p1, const void *p2)
        int ret;
 
        ret = mpz_cmp(expr_value(e1)->value, expr_value(e2)->value);
-       if (ret == 0 && (e1->flags & EXPR_F_INTERVAL_END))
-               return -1;
-       else
-               return 1;
+       if (ret == 0) {
+               if (e1->flags & EXPR_F_INTERVAL_END)
+                       return -1;
+               else if (e2->flags & EXPR_F_INTERVAL_END)
+                       return 1;
+       }
 
        return ret;
 }