]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
lib/utils: fixed full subnet mask length calc
authorMarek Vavrusa <marek@vavrusa.com>
Thu, 16 Jun 2016 17:11:54 +0000 (10:11 -0700)
committerMarek Vavrusa <marek@vavrusa.com>
Thu, 16 Jun 2016 17:14:11 +0000 (10:14 -0700)
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

lib/utils.c

index 00e5d65fe86296529f60844fe64b04b3d86896cb..782bd71630091b27a335f47943fce989c17d8603 100644 (file)
@@ -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);