]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
valgrind: initialize some buffers to make valgrind happy
authorVincent Bernat <bernat@luffy.cx>
Tue, 1 May 2012 08:16:10 +0000 (10:16 +0200)
committerVincent Bernat <bernat@luffy.cx>
Tue, 1 May 2012 08:16:10 +0000 (10:16 +0200)
Valgrind does not understand some ioctl and thinks we are using
unitialized buffers while the ioctl will initialize them. We get rid
of those warnings by initializing them ourselves.

src/interfaces.c
src/privsep_fdpass.c

index e22dd115d4acce48e51f770a3b0c3f3ad1ba3fbd..e9ce4cefe086f0fed78a3011b472a1d5a42ce990 100644 (file)
@@ -440,6 +440,7 @@ iface_minimal_checks(struct lldpd *cfg, struct ifaddrs *ifa)
        /* Check if the driver is whitelisted */
        memset(&ifr, 0, sizeof(ifr));
        strcpy(ifr.ifr_name, ifa->ifa_name);
+       memset(&ethc, 0, sizeof(ethc));
        ifr.ifr_data = (caddr_t) &ethc;
        ethc.cmd = ETHTOOL_GDRVINFO;
        if (ioctl(cfg->g_sock, SIOCETHTOOL, &ifr) == 0) {
@@ -470,10 +471,11 @@ iface_minimal_checks(struct lldpd *cfg, struct ifaddrs *ifa)
 static int
 iface_set_filter(const char *name, int fd)
 {
-       const struct sock_fprog prog = {
-               .filter = lldpd_filter_f,
-               .len = sizeof(lldpd_filter_f) / sizeof(struct sock_filter)
-       };
+       struct sock_fprog prog;
+       memset(&prog, 0, sizeof(struct sock_fprog));
+       prog.filter = lldpd_filter_f;
+       prog.len = sizeof(lldpd_filter_f) / sizeof(struct sock_filter);
+
        if (setsockopt(fd, SOL_SOCKET, SO_ATTACH_FILTER,
                 &prog, sizeof(prog)) < 0) {
                LLOG_WARN("unable to change filter for %s", name);
index 4a1a3140741cac77fb2e9798dfd2fecbf1024b29..6b004806a9bb902fb89ac9170d70be919a4a50ea 100644 (file)
@@ -60,6 +60,7 @@ send_fd(int sock, int fd)
        ssize_t n;
 
        memset(&msg, 0, sizeof(msg));
+       memset(&cmsgbuf.buf, 0, sizeof(cmsgbuf.buf));
 
        if (fd >= 0) {
                msg.msg_control = (caddr_t)&cmsgbuf.buf;