From: Michael Tremer Date: Wed, 30 Mar 2022 15:19:10 +0000 (+0000) Subject: network: loc_network_subnets: Use correct prefix X-Git-Tag: 0.9.13~7 X-Git-Url: http://git.ipfire.org/?p=people%2Fms%2Flibloc.git;a=commitdiff_plain;h=47b55e7060f6714889d2a8a45dd01e3452e2db38 network: loc_network_subnets: Use correct prefix The prefix is being stored as a total number of bits now since it is easier for any bitwise maths later. This is however causing an incorrect prefix being computed when splitting a network into two subnets for IPv4. To get the correct prefix, loc_network_prefix must be called. Introduced in 1fd09d0b09756649968fec42c737c88b92e4f11f Reported-by: Valter Jansons Signed-off-by: Michael Tremer --- diff --git a/src/network.c b/src/network.c index 98c7558..37a483e 100644 --- a/src/network.c +++ b/src/network.c @@ -312,7 +312,7 @@ LOC_EXPORT int loc_network_subnets(struct loc_network* network, *subnet2 = NULL; // New prefix length - unsigned int prefix = network->prefix + 1; + unsigned int prefix = loc_network_prefix(network) + 1; // Check if the new prefix is valid if (!loc_address_valid_prefix(&network->first_address, prefix)) {