summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Jakma <paul@quagga.net>2009-08-08 20:41:39 +0100
committerPaul Jakma <paul@quagga.net>2009-08-28 14:51:49 +0100
commitc4cf095e95ae66c1a7b87bca95e61e50fec746ee (patch)
tree368c8688e2bbe6cdffa46c28d4480c1496449f48
parentfab7f89dcfe77cf06806e7f8a33314d3b4857a69 (diff)
lib/trivial: str2prefix checks return of inet_pton in fragile way
* prefix.c: (str2prefix_ipv6) inet_pton succesful return is presumed to be 1, rather than the "not zero" the man page describes - seemed fragile.
-rw-r--r--lib/prefix.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/prefix.c b/lib/prefix.c
index c6922036..2afaa09c 100644
--- a/lib/prefix.c
+++ b/lib/prefix.c
@@ -379,7 +379,7 @@ str2prefix_ipv6 (const char *str, struct prefix_ipv6 *p)
if (pnt == NULL)
{
ret = inet_pton (AF_INET6, str, &p->prefix);
- if (ret != 1)
+ if (ret == 0)
return 0;
p->prefixlen = IPV6_MAX_BITLEN;
}
@@ -392,7 +392,7 @@ str2prefix_ipv6 (const char *str, struct prefix_ipv6 *p)
*(cp + (pnt - str)) = '\0';
ret = inet_pton (AF_INET6, cp, &p->prefix);
free (cp);
- if (ret != 1)
+ if (ret == 0)
return 0;
plen = (u_char) atoi (++pnt);
if (plen > 128)