From patchwork Wed Apr 18 18:33:27 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: libmnl: fix valgrind warnings about padding Date: Wed, 18 Apr 2012 08:33:27 -0000 From: stephen hemminger X-Patchwork-Id: 153562 Message-Id: <20120418113327.3d26501b@nehalam.linuxnetplumber.net> To: Pablo Neira Ayuso Cc: netfilter-devel@vger.kernel.org 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. --- To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html --- a/src/nlmsg.c +++ b/src/nlmsg.c @@ -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);