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

Laine Stump laine at laine.org
Fri Jan 16 15:22:08 UTC 2015


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())




More information about the libvir-list mailing list