From 8dd290b85ee8d57026581891e9a34945d077fa3b Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Sat, 19 Jul 2014 14:42:47 +0200 Subject: [PATCH] options: fix logic flaw when parsing ipaddr/mask notation Signed-off-by: Jo-Philipp Wich --- options.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/options.c b/options.c index 292f5fc..0a796a4 100644 --- a/options.c +++ b/options.c @@ -268,12 +268,15 @@ fw3_parse_address(void *ptr, const char *val, bool is_list) addr.family = FW3_FAMILY_V6; addr.address.v6 = v6; - if (m && !inet_pton(AF_INET6, m, &addr.mask.v6)) + if (m) { - bits = strtol(m, &e, 10); + if (!inet_pton(AF_INET6, m, &v6)) + { + bits = strtol(m, &e, 10); - if ((*e != 0) || !fw3_bitlen2netmask(addr.family, bits, &v6)) - goto fail; + if ((*e != 0) || !fw3_bitlen2netmask(addr.family, bits, &v6)) + goto fail; + } addr.mask.v6 = v6; } @@ -294,12 +297,15 @@ fw3_parse_address(void *ptr, const char *val, bool is_list) addr.family = FW3_FAMILY_V4; addr.address.v4 = v4; - if (m && !inet_pton(AF_INET, m, &addr.mask.v4)) + if (m) { - bits = strtol(m, &e, 10); + if (!inet_pton(AF_INET, m, &v4)) + { + bits = strtol(m, &e, 10); - if ((*e != 0) || !fw3_bitlen2netmask(addr.family, bits, &v4)) - goto fail; + if ((*e != 0) || !fw3_bitlen2netmask(addr.family, bits, &v4)) + goto fail; + } addr.mask.v4 = v4; } -- 2.25.1