From faaca263b9cde65dc4573b799742204b79d0fdda Mon Sep 17 00:00:00 2001 From: luis Date: Wed, 22 Sep 2010 09:41:06 +0000 Subject: [PATCH] When using pcap_set_filter() on Linux, valgrind complains about a setsockopt() call that uses a pointer to some uninitialized memory. The error message is the following: ==22214== Syscall param socketcall.setsockopt(optval) points to uninitialised byte(s) ==22214== at 0x62F774A: setsockopt (syscall-template.S:82) ==22214== by 0x4E33B85: ??? (in /usr/lib/libpcap.so.1.0.0) ==22214== by 0x4E33D0D: ??? (in /usr/lib/libpcap.so.1.0.0) ==22214== by 0x432253: nsock_pcap_set_filter (in /usr/local/bin/nping) ==22214== by 0x432557: nsock_pcap_open (in /usr/local/bin/nping) ==22214== by 0x4295FF: ProbeMode::start() (in /usr/local/bin/nping) ==22214== by 0x40B2E1: main (in /usr/local/bin/nping) This patch adds a simple memset() call that makes the warning dissapear. --- libpcap/pcap-linux.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libpcap/pcap-linux.c b/libpcap/pcap-linux.c index dedfb6dc4..ca06fab99 100644 --- a/libpcap/pcap-linux.c +++ b/libpcap/pcap-linux.c @@ -2148,6 +2148,7 @@ pcap_setfilter_linux_common(pcap_t *handle, struct bpf_program *filter, struct sock_fprog fcode; int can_filter_in_kernel; int err = 0; + memset(&fcode, 0, sizeof(struct sock_fprog)); #endif if (!handle)