Let clang warning shut up and initialize the allocated area
with zeroes.

  CC    net/bpf.o
net/bpf.c:297:16: warning: The left expression of the compound assignment
       is an uninitialized value. The computed value will also be garbage
                curr[1].code |= (uint16_t) rand();
                ~~~~~~~~~~~~ ^
net/bpf.c:299:16: warning: The left expression of the compound assignment
       is an uninitialized value. The computed value will also be garbage
                curr[2].code |= (uint16_t) rand();
                ~~~~~~~~~~~~ ^

Reported-by: Dave Jones <[email protected]>
Signed-off-by: Daniel Borkmann <[email protected]>
---
 net/bpf.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/net/bpf.c b/net/bpf.c
index cc748de..bda72e1 100644
--- a/net/bpf.c
+++ b/net/bpf.c
@@ -338,11 +338,15 @@ void gen_seccomp_bpf(unsigned long *addr, unsigned long 
*addrlen)
                return;
        }
 
+       memset(bpf->filter, 0, bpf->len * sizeof(struct sock_filter));
+
        seccomp_state = seccomp_choose(seccomp_markov_init);
+
        for (curr = bpf->filter; avail > 3; ) {
                used = gen_seccomp_bpf_code(curr);
                curr  += used;
                avail -= used;
+
                seccomp_state = seccomp_choose(seccomp_markov[seccomp_state]);
        }
 
-- 
1.7.11.7

--
To unsubscribe from this list: send the line "unsubscribe trinity" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to