From: Michael Tremer Date: Wed, 30 Mar 2022 15:15:00 +0000 (+0000) Subject: network: Log a more useful message on invalid prefix X-Git-Tag: 0.9.13~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=92ba094c7f1f2ce9e9fa2c80fa042701e3327872;p=location%2Flibloc.git network: Log a more useful message on invalid prefix If loc_network_subnets is being called with some invalid input, we just fail without logging a useful message or setting errno accordingly. This is being changed with this patch. Signed-off-by: Michael Tremer --- diff --git a/src/network.c b/src/network.c index b720a0a..0b469e2 100644 --- a/src/network.c +++ b/src/network.c @@ -315,8 +315,11 @@ LOC_EXPORT int loc_network_subnets(struct loc_network* network, unsigned int prefix = network->prefix + 1; // Check if the new prefix is valid - if (!loc_address_valid_prefix(&network->first_address, prefix)) - return -1; + if (!loc_address_valid_prefix(&network->first_address, prefix)) { + ERROR(network->ctx, "Invalid prefix: %d\n", prefix); + errno = EINVAL; + return 1; + } // Create the first half of the network r = loc_network_new(network->ctx, subnet1, &network->first_address, prefix);