]> git.ipfire.org Git - people/ms/libloc.git/commitdiff
network: loc_network_subnets: Use correct prefix
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 30 Mar 2022 15:19:10 +0000 (15:19 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 30 Mar 2022 15:19:10 +0000 (15:19 +0000)
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 <valter.jansons@gmail.com>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/network.c

index 98c7558b2b3e7ef3fd09297728d3ed80a9f916af..37a483eaf0b33b32406bd87e9adc8445fa84fdfa 100644 (file)
@@ -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)) {