diff mbox

libmnl: fix valgrind warnings about padding

Message ID 20120418113327.3d26501b@nehalam.linuxnetplumber.net
State Accepted
Headers show

Commit Message

stephen hemminger April 18, 2012, 6:33 p.m. UTC
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

Comments

Pablo Neira Ayuso April 18, 2012, 10:56 p.m. UTC | #1
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
diff mbox

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