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-nit.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'pcap-nit.c') diff --git a/pcap-nit.c b/pcap-nit.c index c15704b..524d8c3 100644 --- a/pcap-nit.c +++ b/pcap-nit.c @@ -20,7 +20,7 @@ */ #ifndef lint static const char rcsid[] = - "@(#) $Header: /tcpdump/master/libpcap/pcap-nit.c,v 1.38 2000-10-12 03:54:00 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/libpcap/pcap-nit.c,v 1.39 2000-10-28 00:01:29 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -245,6 +245,7 @@ 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