aboutsummaryrefslogtreecommitdiffstats
path: root/pcap-null.c
diff options
context:
space:
mode:
authorguy <guy>2000-10-28 00:01:26 +0000
committerguy <guy>2000-10-28 00:01:26 +0000
commit82547471f79c2cf4a9943a222d006edc4add2d76 (patch)
tree803d1cceed386d4025205dc5ae836cc38d62b6a9 /pcap-null.c
parent188fee53ccbbe6b11e84ae01b10955205be5ac62 (diff)
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.
Diffstat (limited to 'pcap-null.c')
-rw-r--r--pcap-null.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/pcap-null.c b/pcap-null.c
index 588c4d3..e952c98 100644
--- a/pcap-null.c
+++ b/pcap-null.c
@@ -20,7 +20,7 @@
*/
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/libpcap/pcap-null.c,v 1.12 2000-07-11 00:37:06 assar Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/libpcap/pcap-null.c,v 1.13 2000-10-28 00:01:29 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -68,6 +68,7 @@ pcap_setfilter(pcap_t *p, struct bpf_program *fp)
"pcap_setfilter: %s", nosup);
return (-1);
}
- p->fcode = *fp;
+ if (install_bpf_program(p, fp) < 0)
+ return (-1);
return (0);
}