summaryrefslogtreecommitdiff
path: root/libnfnetlink/0004-libnfnetlink-initialize-attribute-padding-to-resolve.patch
blob: cf3a841356ca3e968a5b2d83ba35c49787946bf6 (plain)
    1 From b142da8d2c9e2e2dfbe4e89e680dd124f6064ac8 Mon Sep 17 00:00:00 2001
    2 From: Pablo Neira Ayuso <pablo@netfilter.org>
    3 Date: Mon, 3 Feb 2014 12:09:29 +0100
    4 Subject: [PATCH 4/6] libnfnetlink: initialize attribute padding to resolve
    5  valgrind warnings
    6 
    7 ==12195== Syscall param socketcall.sendto(msg) points to uninitialised byte(s)
    8 ==12195==    at 0x51209C3: __sendto_nocancel (syscall-template.S:81)
    9 ==12195==    by 0x53E4D12: nfnl_send (libnfnetlink.c:391)
   10 ==12195==    by 0x53E6952: nfnl_query (libnfnetlink.c:1569)
   11 ==12195==    by 0x4E344AF: __build_send_cfg_msg.isra.1 (libnetfilter_log.c:143)
   12 ==12195==    by 0x4E34710: nflog_bind_group (libnetfilter_log.c:413)
   13 ==12195==    by 0x400CB1: main (nfulnl_test.c:77)
   14 ==12195==  Address 0x7fefff3e9 is on thread 1's stack
   15 
   16 This patch sets to zero the padding that is included to align the
   17 attribute payload.
   18 
   19 Reported-by: Ivan Homoliak <xhomol11@gmail.com>
   20 Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
   21 ---
   22  src/libnfnetlink.c | 1 +
   23  1 file changed, 1 insertion(+)
   24 
   25 diff --git a/src/libnfnetlink.c b/src/libnfnetlink.c
   26 index 4b2bcd0..398b7d7 100644
   27 --- a/src/libnfnetlink.c
   28 +++ b/src/libnfnetlink.c
   29 @@ -809,6 +809,7 @@ int nfnl_addattr_l(struct nlmsghdr *n, int maxlen, int type, const void *data,
   30  	nfa->nfa_type = type;
   31  	nfa->nfa_len = len;
   32  	memcpy(NFA_DATA(nfa), data, alen);
   33 +	memset((uint8_t *)nfa + nfa->nfa_len, 0, NFA_ALIGN(alen) - alen);
   34  	n->nlmsg_len = (NLMSG_ALIGN(n->nlmsg_len) + NFA_ALIGN(len));
   35  	return 0;
   36  }
   37 -- 
   38 2.12.1

Generated by cgit