From 92ba094c7f1f2ce9e9fa2c80fa042701e3327872 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Wed, 30 Mar 2022 15:15:00 +0000 Subject: [PATCH] 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 --- src/network.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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); -- 2.39.2