diff options
author | guy <guy> | 2000-10-28 00:01:26 +0000 |
---|---|---|
committer | guy <guy> | 2000-10-28 00:01:26 +0000 |
commit | 82547471f79c2cf4a9943a222d006edc4add2d76 (patch) | |
tree | 803d1cceed386d4025205dc5ae836cc38d62b6a9 /pcap-snit.c | |
parent | 188fee53ccbbe6b11e84ae01b10955205be5ac62 (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-snit.c')
-rw-r--r-- | pcap-snit.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/pcap-snit.c b/pcap-snit.c index e20a28ae..47818e4f 100644 --- a/pcap-snit.c +++ b/pcap-snit.c @@ -25,7 +25,7 @@ #ifndef lint static const char rcsid[] = - "@(#) $Header: /tcpdump/master/libpcap/pcap-snit.c,v 1.53 2000-10-12 03:54:00 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/libpcap/pcap-snit.c,v 1.54 2000-10-28 00:01:30 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -302,6 +302,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); } |