firewall3: fix left shift on 64 bit systems in fw3_bitlen2netmask
authorUlrich Weber <uweber.linux@gmail.com>
Mon, 5 Jan 2015 14:58:34 +0000 (15:58 +0100)
committerJo-Philipp Wich <jow@openwrt.org>
Thu, 8 Jan 2015 14:30:37 +0000 (15:30 +0100)
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@ocedo.com>
utils.c

diff --git a/utils.c b/utils.c
index 71a0f13b269970d6162c6506ec161d43eeff2faf..b2fbe0223c6d7338600654c09750a7d2a5b9622a 100644 (file)
--- 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;