Blame SOURCES/conntrack-Fix-CIDR-to-mask-conversion-on-Big-Endian.patch

7a4b38
From bc5b42cd12b9fadfbeff96fc3bd5ab7d67f5f253 Mon Sep 17 00:00:00 2001
7a4b38
From: Phil Sutter <phil@nwl.cc>
7a4b38
Date: Mon, 2 Sep 2019 18:39:51 +0200
7a4b38
Subject: [PATCH] conntrack: Fix CIDR to mask conversion on Big Endian
7a4b38
7a4b38
Code assumed host architecture to be Little Endian. Instead produce a
7a4b38
proper mask by pushing the set bits into most significant position and
7a4b38
apply htonl() on the result.
7a4b38
7a4b38
Fixes: 3f6a2e90936bb ("conntrack: add support for CIDR notation")
7a4b38
Signed-off-by: Phil Sutter <phil@nwl.cc>
7a4b38
Acked-by: Pablo Neira Ayuso <pablo@netfilter.org>
7a4b38
(cherry picked from commit f27901afb038b07532b4c31cb77bbc0bd8068253)
7a4b38
Signed-off-by: Phil Sutter <psutter@redhat.com>
7a4b38
---
7a4b38
 src/conntrack.c | 2 +-
7a4b38
 1 file changed, 1 insertion(+), 1 deletion(-)
7a4b38
7a4b38
diff --git a/src/conntrack.c b/src/conntrack.c
7a4b38
index ff030fe54e103..7a9aca4966f25 100644
7a4b38
--- a/src/conntrack.c
7a4b38
+++ b/src/conntrack.c
7a4b38
@@ -2138,7 +2138,7 @@ nfct_build_netmask(uint32_t *dst, int b, int n)
7a4b38
 			dst[i] = 0xffffffff;
7a4b38
 			b -= 32;
7a4b38
 		} else if (b > 0) {
7a4b38
-			dst[i] = (1 << b) - 1;
7a4b38
+			dst[i] = htonl(~0u << (32 - b));
7a4b38
 			b = 0;
7a4b38
 		} else {
7a4b38
 			dst[i] = 0;
7a4b38
-- 
7a4b38
2.24.0
7a4b38