diff options
author | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2010-12-06 14:59:06 -0800 |
---|---|---|
committer | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2010-12-06 14:59:06 -0800 |
commit | 2553042a7a687c5bc90ad9a19da742b8829bbd73 (patch) | |
tree | 09e6d05b5cf10c12d300a1831a4c051a48db7e35 | |
parent | 2e149c781206918062fbec64d4c672d47d5ba004 (diff) | |
download | vyatta-cfg-system-2553042a7a687c5bc90ad9a19da742b8829bbd73.tar.gz vyatta-cfg-system-2553042a7a687c5bc90ad9a19da742b8829bbd73.zip |
Fix check for unspecified IPv6 address
Bug 6514
-rw-r--r-- | src/valid_address.c | 45 |
1 files changed, 18 insertions, 27 deletions
diff --git a/src/valid_address.c b/src/valid_address.c index a98d0f56..2f93c257 100644 --- a/src/valid_address.c +++ b/src/valid_address.c @@ -90,45 +90,36 @@ static int valid_ipv6(char *str) char *slash, *endp; slash = strchr(str, '/'); - if (!slash) - goto bad_addr; /* Missing slash */ + if (!slash) { + fprintf(stderr, "Missing network prefix\n"); + return 0; + } *slash++ = 0; prefix_len = strtoul(slash, &endp, 10); if (*slash == '\0' || *endp != '\0') - goto bad_addr; /* Non-digit in prefix length */ + fprintf(stderr, "Non-digit in prefix length\n"); + + else if (prefix_len <= 1 || prefix_len > 128) + fprintf(stderr, + "Invalid prefix len %d for IPv6\n", prefix_len); - if (inet_pton(AF_INET6, str, &addr) <= 0) - goto bad_addr; /* Not a valid IPv6 address */ + else if (inet_pton(AF_INET6, str, &addr) <= 0) + fprintf(stderr, "Invalid IPv6 address\n"); - if (IN6_IS_ADDR_LINKLOCAL(&addr)) { + else if (IN6_IS_ADDR_LINKLOCAL(&addr)) fprintf(stderr, "Can not assign an address reserved for IPv6 link local\n"); - return 0; - } - - if (IN6_IS_ADDR_MULTICAST(&addr)) { + else if (IN6_IS_ADDR_MULTICAST(&addr)) fprintf(stderr, "Can not assign an address reserved for IPv6 multicast\n"); - return 0; - } - - if (prefix_len <= 1 || prefix_len > 128) { + else if (IN6_IS_ADDR_UNSPECIFIED(&addr)) fprintf(stderr, - "Invalid prefix len %d for IPv6\n", prefix_len); - return 0; - } - - if (prefix_len == 128) { - fprintf(stderr, - "Can not assign IPv6 Unspecified address\n"); - return 0; - } - return 1; + "Can not assign IPv6 reserved for IPv6 unspecified address\n"); + else + return 1; /* is valid address and prefix */ - bad_addr: - fprintf(stderr, "Invalid IPv6 address/prefix\n"); - return 0; + return 0; /* Invalid address */ } |