From 098b7d6add425aadb0cfe5af34c5d88d5320d33f Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Tue, 18 Jun 2013 16:11:56 +0200 Subject: [PATCH] Fix processing of CIDRs with mask 0 --- iptables.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/iptables.c b/iptables.c index df0d704..7d91452 100644 --- a/iptables.c +++ b/iptables.c @@ -609,7 +609,10 @@ fw3_ipt_rule_in_out(struct fw3_ipt_rule *r, static void ip4prefix2mask(int prefix, struct in_addr *mask) { - mask->s_addr = htonl(~((1 << (32 - prefix)) - 1)); + if (prefix > 0) + mask->s_addr = htonl(~((1 << (32 - prefix)) - 1)); + else + mask->s_addr = 0; } #ifndef DISABLE_IPV6 -- 2.25.1