From: Michael Tremer Date: Sat, 17 Feb 2024 21:12:32 +0000 (+0000) Subject: network: Fix bit length check when merging networks X-Git-Tag: 0.9.18~196 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f6d762e0bb27bb50ac705ca242394f9a647de2e2;p=location%2Flibloc.git network: Fix bit length check when merging networks The check was incorrect as it only expected perfect matches, but we can of course also merge subnets that don't necessarily require the entire prefix length for the start address. Signed-off-by: Michael Tremer --- diff --git a/src/network.c b/src/network.c index 47fe735..07da2b0 100644 --- a/src/network.c +++ b/src/network.c @@ -602,7 +602,7 @@ static int loc_network_merge(struct loc_network** n, const size_t bitlength = loc_address_bit_length(&n1->first_address) - 1; // We cannot shorten this any more - if (bitlength == prefix) + if (bitlength < prefix) return 0; // Increment the last address of the first network