[OpenWrt-Devel] [PATCH] firewall3: fix left shift on 64 bit systems in fw3_bitlen2netmask

Ulrich Weber uweber.linux at gmail.com
Mon Jan 5 09:58:34 EST 2015


otherwise 0.0.0.0/0 is set as 0.0.0.0/255.255.255.255 on x86_64

Signed-off-by: Ulrich Weber <uw at ocedo.com>
---
 utils.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/utils.c b/utils.c
index 71a0f13..b2fbe02 100644
--- a/utils.c
+++ b/utils.c
@@ -803,7 +803,7 @@ fw3_bitlen2netmask(int family, int bits, void *mask)
 			return false;
 
 		v4 = mask;
-		v4->s_addr = htonl(~((1 << (32 - abs(bits))) - 1));
+		v4->s_addr = bits ? htonl(~((1 << (32 - abs(bits))) - 1)) : 0;
 
 		if (bits < 0)
 			v4->s_addr = ~v4->s_addr;
-- 
1.9.1
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list