Blob Blame History Raw
From 4237aad9c04ac6a82756545a49ae8e9bd0fe9fac Mon Sep 17 00:00:00 2001
From: Phil Sutter <phil@nwl.cc>
Date: Mon, 12 Nov 2018 17:50:27 +0100
Subject: [PATCH] extensions: among: Fix bitmask check

Boolean AND was applied instead of binary one, causing the exclamation
mark to be printed whenever info->bitmask was non-zero. In practice,
this leads to incorrect output if e.g. --among-src was given with an
inverted match as well as --among-dst with a non-inverted one. Output
would then list both matches as inverted.

Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Phil Sutter <psutter@redhat.com>
---
 extensions/ebt_among.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/extensions/ebt_among.c b/extensions/ebt_among.c
index b1560e8f09e8d..30c098cf69f96 100644
--- a/extensions/ebt_among.c
+++ b/extensions/ebt_among.c
@@ -436,14 +436,14 @@ static void print(const struct ebt_u_entry *entry,
 
 	if (info->wh_dst_ofs) {
 		printf("--among-dst ");
-		if (info->bitmask && EBT_AMONG_DST_NEG) {
+		if (info->bitmask & EBT_AMONG_DST_NEG) {
 			printf("! ");
 		}
 		wormhash_printout(ebt_among_wh_dst(info));
 	}
 	if (info->wh_src_ofs) {
 		printf("--among-src ");
-		if (info->bitmask && EBT_AMONG_SRC_NEG) {
+		if (info->bitmask & EBT_AMONG_SRC_NEG) {
 			printf("! ");
 		}
 		wormhash_printout(ebt_among_wh_src(info));
-- 
2.21.0