X-Git-Url: https://tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Fconf.c;h=ff592a866c2b4422ab0ed74ebcd7d510d8092d0a;hb=c79f93d90fdb12c839ca59336e9bf571e8cbbcaa;hp=0b84ad71ee4a84aece0d2563c055a8ec74c7967a;hpb=1c475ecb575367a6b3f9328b0f643ad636155341;p=tinc diff --git a/src/conf.c b/src/conf.c index 0b84ad71..ff592a86 100644 --- a/src/conf.c +++ b/src/conf.c @@ -4,7 +4,7 @@ 1998-2005 Ivo Timmermans 2000 Cris van Pelt 2010-2011 Julien Muchembled - 2000-2015 Guus Sliepen + 2000-2021 Guus Sliepen 2013 Florent Clairambault This program is free software; you can redistribute it and/or modify @@ -80,18 +80,9 @@ config_t *new_config(void) { } void free_config(config_t *cfg) { - if(cfg->variable) { - free(cfg->variable); - } - - if(cfg->value) { - free(cfg->value); - } - - if(cfg->file) { - free(cfg->file); - } - + free(cfg->variable); + free(cfg->value); + free(cfg->file); free(cfg); } @@ -215,20 +206,14 @@ bool get_config_subnet(const config_t *cfg, subnet_t **result) { return false; } - /* Teach newbies what subnets are... */ - - if(((subnet.type == SUBNET_IPV4) - && !maskcheck(&subnet.net.ipv4.address, subnet.net.ipv4.prefixlength, sizeof(subnet.net.ipv4.address))) - || ((subnet.type == SUBNET_IPV6) - && !maskcheck(&subnet.net.ipv6.address, subnet.net.ipv6.prefixlength, sizeof(subnet.net.ipv6.address)))) { - logger(DEBUG_ALWAYS, LOG_ERR, "Network address and prefix length do not match for configuration variable %s in %s line %d", - cfg->variable, cfg->file, cfg->line); - return false; + if(subnetcheck(subnet)) { + *(*result = new_subnet()) = subnet; + return true; } - *(*result = new_subnet()) = subnet; - - return true; + logger(DEBUG_ALWAYS, LOG_ERR, "Network address and prefix length do not match for configuration variable %s in %s line %d", + cfg->variable, cfg->file, cfg->line); + return false; } /*