From fa236ecc2cd4ba6e80516064120b7201337f0ff5 Mon Sep 17 00:00:00 2001 From: bol-van Date: Mon, 12 Dec 2022 21:51:04 +0300 Subject: [PATCH] ip2net: fix ipv4 mask for /0 --- ip2net/ip2net.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ip2net/ip2net.c b/ip2net/ip2net.c index 83bddc1..b589939 100644 --- a/ip2net/ip2net.c +++ b/ip2net/ip2net.c @@ -49,7 +49,7 @@ static int ucmp(const void * a, const void * b, void *arg) } static uint32_t mask_from_bitcount(uint32_t zct) { - return ~((1 << zct) - 1); + return zct<32 ? ~((1 << zct) - 1) : 0; } // make presorted array unique. return number of unique items. // 1,1,2,3,3,0,0,0 (ct=8) => 1,2,3,0 (ct=4)