Skip to contentSkip to conversation

libmnl: fix valgrind warnings about padding

PATCH Applied Stephen Hemminger 2 participants 2 messages Apr 18, 2012 netfilter

lore
Share & tools
lore
#0 lore raw

When using mnl_nlmsg_put_extra_header() it pads out the addtional header but only zeros the original size not the padded value. Which cause valgrind to complain about sendto() with unitialized byte.

src/nlmsg.c +3 -2
@@ -105,8 +105,9 @@ void *
 mnl_nlmsg_put_extra_header(struct nlmsghdr *nlh, size_t size)
 {
        char *ptr = (char *)nlh + nlh->nlmsg_len;
-       nlh->nlmsg_len += MNL_ALIGN(size);
-       memset(ptr, 0, size);
+       size_t len = MNL_ALIGN(size);
+       nlh->nlmsg_len += len;
+       memset(ptr, 0, len);
        return ptr;
 }
 EXPORT_SYMBOL(mnl_nlmsg_put_extra_header);
maintainer Applied
#1 lore raw
Quoted 3 lines · Stephen Hemminger

When using mnl_nlmsg_put_extra_header() it pads out the addtional header but only zeros the original size not the padded value. Which cause valgrind to complain about sendto() with unitialized byte.

Applied, thanks Stephen.