mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-06 16:20:08 +00:00
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.
This commit is contained in:
parent
fab7f89dcf
commit
c4cf095e95
@ -379,7 +379,7 @@ str2prefix_ipv6 (const char *str, struct prefix_ipv6 *p)
|
|||||||
if (pnt == NULL)
|
if (pnt == NULL)
|
||||||
{
|
{
|
||||||
ret = inet_pton (AF_INET6, str, &p->prefix);
|
ret = inet_pton (AF_INET6, str, &p->prefix);
|
||||||
if (ret != 1)
|
if (ret == 0)
|
||||||
return 0;
|
return 0;
|
||||||
p->prefixlen = IPV6_MAX_BITLEN;
|
p->prefixlen = IPV6_MAX_BITLEN;
|
||||||
}
|
}
|
||||||
@ -392,7 +392,7 @@ str2prefix_ipv6 (const char *str, struct prefix_ipv6 *p)
|
|||||||
*(cp + (pnt - str)) = '\0';
|
*(cp + (pnt - str)) = '\0';
|
||||||
ret = inet_pton (AF_INET6, cp, &p->prefix);
|
ret = inet_pton (AF_INET6, cp, &p->prefix);
|
||||||
free (cp);
|
free (cp);
|
||||||
if (ret != 1)
|
if (ret == 0)
|
||||||
return 0;
|
return 0;
|
||||||
plen = (u_char) atoi (++pnt);
|
plen = (u_char) atoi (++pnt);
|
||||||
if (plen > 128)
|
if (plen > 128)
|
||||||
|
Loading…
Reference in New Issue
Block a user