netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [nft PATCH] segtree: Fix expr_value_cmp()
@ 2017-07-06 14:25 Phil Sutter
  2017-07-06 14:48 ` Phil Sutter
  0 siblings, 1 reply; 2+ messages in thread
From: Phil Sutter @ 2017-07-06 14:25 UTC (permalink / raw)
  To: Pablo Neira Ayuso; +Cc: netfilter-devel

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>
---
 src/segtree.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/segtree.c b/src/segtree.c
index a2316a7b98041..f53536210018d 100644
--- a/src/segtree.c
+++ b/src/segtree.c
@@ -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;
 }
-- 
2.13.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [nft PATCH] segtree: Fix expr_value_cmp()
  2017-07-06 14:25 [nft PATCH] segtree: Fix expr_value_cmp() Phil Sutter
@ 2017-07-06 14:48 ` Phil Sutter
  0 siblings, 0 replies; 2+ messages in thread
From: Phil Sutter @ 2017-07-06 14:48 UTC (permalink / raw)
  To: Pablo Neira Ayuso; +Cc: netfilter-devel

On Thu, Jul 06, 2017 at 04:25:28PM +0200, Phil Sutter wrote:
> 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.
> 

Fixes: 0e5f289df9080 ("segtree: handle adjacent interval nodes from expr_value_cmp()")

Sorry for the mess. :(


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-07-06 14:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-06 14:25 [nft PATCH] segtree: Fix expr_value_cmp() Phil Sutter
2017-07-06 14:48 ` Phil Sutter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).