]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
util: fix more coverity warnings
authorMiroslav Lichvar <mlichvar@redhat.com>
Mon, 30 Jan 2017 09:55:40 +0000 (10:55 +0100)
committerMiroslav Lichvar <mlichvar@redhat.com>
Tue, 31 Jan 2017 10:22:10 +0000 (11:22 +0100)
Coverity doesn't seem to like the new field in the IPAddr struct (used
as explicit padding of the structure) to be left uninitialized, even
though it's never used for anything and is cleared by memset() in
UTI_IPHostToNetwork() before leaving the process.

util.c

diff --git a/util.c b/util.c
index 977580a6edade004595de3a4ab6fac5bb16293e3..a9355ca63d9896bec257710d93833efd68ff5061 100644 (file)
--- a/util.c
+++ b/util.c
@@ -329,12 +329,14 @@ UTI_StringToIP(const char *addr, IPAddr *ip)
 
   if (inet_pton(AF_INET, addr, &in4) > 0) {
     ip->family = IPADDR_INET4;
+    ip->_pad = 0;
     ip->addr.in4 = ntohl(in4.s_addr);
     return 1;
   }
 
   if (inet_pton(AF_INET6, addr, &in6) > 0) {
     ip->family = IPADDR_INET6;
+    ip->_pad = 0;
     memcpy(ip->addr.in6, in6.s6_addr, sizeof (ip->addr.in6));
     return 1;
   }
@@ -344,6 +346,7 @@ UTI_StringToIP(const char *addr, IPAddr *ip)
   n = sscanf(addr, "%lu.%lu.%lu.%lu", &a, &b, &c, &d);
   if (n == 4) {
     ip->family = IPADDR_INET4;
+    ip->_pad = 0;
     ip->addr.in4 = ((a & 0xff) << 24) | ((b & 0xff) << 16) | 
                    ((c & 0xff) << 8) | (d & 0xff);
     return 1;
@@ -442,6 +445,7 @@ void
 UTI_IPNetworkToHost(IPAddr *src, IPAddr *dest)
 {
   dest->family = ntohs(src->family);
+  dest->_pad = 0;
 
   switch (dest->family) {
     case IPADDR_INET4: