[libvirt] [PATCHv2] Coverity fix: properly check for 0 ipv6 address.

--- src/util/virsocketaddr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/virsocketaddr.c b/src/util/virsocketaddr.c index 91bcadf..67ed330 100644 --- a/src/util/virsocketaddr.c +++ b/src/util/virsocketaddr.c @@ -850,7 +850,7 @@ virSocketAddrGetIpPrefix(const virSocketAddr *address, } return -1; } else if (VIR_SOCKET_ADDR_IS_FAMILY(address, AF_INET6)) { - if (address->data.inet6.sin6_addr.s6_addr == 0) + if (virSocketAddrIsWildcard(address)) return 0; return 64; } -- 2.1.2

On 01/16/2015 09:51 AM, Cédric Bosdonnat wrote:
--- src/util/virsocketaddr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/util/virsocketaddr.c b/src/util/virsocketaddr.c index 91bcadf..67ed330 100644 --- a/src/util/virsocketaddr.c +++ b/src/util/virsocketaddr.c @@ -850,7 +850,7 @@ virSocketAddrGetIpPrefix(const virSocketAddr *address, } return -1; } else if (VIR_SOCKET_ADDR_IS_FAMILY(address, AF_INET6)) { - if (address->data.inet6.sin6_addr.s6_addr == 0) + if (virSocketAddrIsWildcard(address)) return 0; return 64; }
According to sockettest.c, that function does work for "::", and examining the macro that it uses (from /usr/include/netinet/in.h) I see that it is doing exactly what we need (checks all 4 uint32s in the address against 0). So ACK. (Nice! We should have been using that all along, instead of parsing out "::" and calling virSocketAddrEqual())

On 01/16/2015 10:22 AM, Laine Stump wrote:
On 01/16/2015 09:51 AM, Cédric Bosdonnat wrote:
--- src/util/virsocketaddr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/util/virsocketaddr.c b/src/util/virsocketaddr.c index 91bcadf..67ed330 100644 --- a/src/util/virsocketaddr.c +++ b/src/util/virsocketaddr.c @@ -850,7 +850,7 @@ virSocketAddrGetIpPrefix(const virSocketAddr *address, } return -1; } else if (VIR_SOCKET_ADDR_IS_FAMILY(address, AF_INET6)) { - if (address->data.inet6.sin6_addr.s6_addr == 0) + if (virSocketAddrIsWildcard(address)) return 0; return 64; }
According to sockettest.c, that function does work for "::", and examining the macro that it uses (from /usr/include/netinet/in.h) I see that it is doing exactly what we need (checks all 4 uint32s in the address against 0). So ACK.
(Nice! We should have been using that all along, instead of parsing out "::" and calling virSocketAddrEqual())
Strange not all patches have hit my inbox, but I see they're on the list and I got this response probably because Laine CC'd me directly. In any case, I ran this change through Coverity and it resolves the issue noted, so ACK from me too. John
participants (3)
-
Cédric Bosdonnat
-
John Ferlan
-
Laine Stump