[libvirt] [PATCH] ipv6 check for :: address

Hi John, Here is a possible fix for the coverity issue you mentioned. Since ipv6 addresses are too big to be converted to a single integer, I just looped over the array... not sure that is the most elegant way to do it. Cédric Bosdonnat (1): Coverity fix: properly check for 0 ipv6 address. src/util/virsocketaddr.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) -- 2.1.2

--- src/util/virsocketaddr.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/util/virsocketaddr.c b/src/util/virsocketaddr.c index 91bcadf..6d13ad9 100644 --- a/src/util/virsocketaddr.c +++ b/src/util/virsocketaddr.c @@ -850,7 +850,14 @@ 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) + bool isZero = true; + size_t i = 0; + for (i = 0; i < 16; i++) + if (address->data.inet6.sin6_addr.s6_addr[i] != 0) { + isZero = true; + break; + } + if (isZero) return 0; return 64; } -- 2.1.2

On 01/16/2015 02:27 PM, Cédric Bosdonnat wrote:
Hi John,
Here is a possible fix for the coverity issue you mentioned. Since ipv6 addresses are too big to be converted to a single integer, I just looped over the array... not sure that is the most elegant way to do it.
Cédric Bosdonnat (1): Coverity fix: properly check for 0 ipv6 address.
src/util/virsocketaddr.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
I don't see the actual patch, but you can use the virSocketAddrIsWildcard helper for the most elegant way. Jan
participants (2)
-
Cédric Bosdonnat
-
Ján Tomko