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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]