From: Marek Vavrusa Date: Thu, 16 Jun 2016 17:11:54 +0000 (-0700) Subject: lib/utils: fixed full subnet mask length calc X-Git-Tag: v1.1.0~79 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=db544c62e243c4c49fdbf7b9b911b907c97e880b;p=thirdparty%2Fknot-resolver.git lib/utils: fixed full subnet mask length calc previously, if no subnet was given (127.0.0.0), it was treated as 127.0.0.0/0. now it is treated as full address length, e.g. 127.0.0.0/32 --- diff --git a/lib/utils.c b/lib/utils.c index 00e5d65fe..782bd7163 100644 --- a/lib/utils.c +++ b/lib/utils.c @@ -293,6 +293,9 @@ int kr_straddr_subnet(void *dst, const char *addr) if (bit_len < 0 || bit_len > max_len) { return kr_error(ERANGE); } + } else { + /* No subnet, use maximal subnet length. */ + bit_len = (family == AF_INET6) ? 128 : 32; } /* Parse address */ int ret = inet_pton(family, addr_str, dst);