From 47b55e7060f6714889d2a8a45dd01e3452e2db38 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Wed, 30 Mar 2022 15:19:10 +0000 Subject: [PATCH] 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 --- src/network.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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)) { -- 2.39.5