Patchwork libmnl: fix valgrind warnings about padding

login
register
mail settings
Submitter stephen hemminger
Date April 18, 2012, 6:33 p.m.
Message ID <20120418113327.3d26501b@nehalam.linuxnetplumber.net>
Download mbox | patch
Permalink /patch/153562/
State Accepted
Headers show

Comments

stephen hemminger - April 18, 2012, 6:33 p.m.
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
Pablo Neira - April 18, 2012, 10:56 p.m.
On Wed, Apr 18, 2012 at 11:33:27AM -0700, Stephen Hemminger wrote:
> 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.
--
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

Patch

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