From 82547471f79c2cf4a9943a222d006edc4add2d76 Mon Sep 17 00:00:00 2001 From: guy Date: Sat, 28 Oct 2000 00:01:26 +0000 Subject: When attaching a "bpf_program" to a "pcap_t" to use as a userland filter, always attach a copy, as "pcap-linux.c" does; that way, after a program uses "pcap_setfilter()", it can safely use "pcap_freecode()" to free up the BPF instructions allocated by "pcap_compile()". Also, always free it up when the "pcap_t" is closed. Get rid of the "pcap_t *" argument to "pcap_freecode()", as it's not necessary. Document "pcap_freecode()", for the benefit of programs that might repeatedly compile filter programs and attach them, so that they can free them up after attaching them and avoid leaking memory for them. --- pcap-dlpi.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'pcap-dlpi.c') diff --git a/pcap-dlpi.c b/pcap-dlpi.c index 608c8a2..153896a 100644 --- a/pcap-dlpi.c +++ b/pcap-dlpi.c @@ -38,7 +38,7 @@ #ifndef lint static const char rcsid[] = - "@(#) $Header: /tcpdump/master/libpcap/pcap-dlpi.c,v 1.61 2000-10-12 03:53:58 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/libpcap/pcap-dlpi.c,v 1.62 2000-10-28 00:01:28 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -555,7 +555,8 @@ int pcap_setfilter(pcap_t *p, struct bpf_program *fp) { - p->fcode = *fp; + if (install_bpf_program(p, fp) < 0) + return (-1); return (0); } -- cgit v1.2.3