NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
lib/51952: libpcap fault applying filter to unactivated handle
>Number: 51952
>Category: lib
>Synopsis: libpcap will fault if an attempt to apply a filter on non-activated handle occurs.
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: lib-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sun Feb 05 20:55:00 +0000 2017
>Originator: bch <brad.harder%gmail.com@localhost>
>Release: NetBSD 7.99.59
>Organization:
method logic digital
>Environment:
System: NetBSD kamloops 7.99.59 NetBSD 7.99.59 (MODULAR) #51: Sun Feb
5 09:44:00 PST 2017
root@kamloops:/usr/src/sys/arch/amd64/compile/obj/MODULAR amd64
Architecture: x86_64
Machine: amd64
>Description:
libpcap faults if one tries to apply a filter to an unactivated pcap handle.
>How-To-Repeat:
...
char errbuf[PCAP_ERRBUF_SIZE];
struct bpf_program fp;
pcap_t *handle = pcap_create("wm0", errbuf);
pcap_compile(handle, &fp, "port 80", 0, PCAP_NETMASK_UNKNOWN); /* not
yet activated... */
// segfault in freechunks()
>Fix:
The compiler state "chunks" initialization is short-circuited if
the handle is not activated, but the chunks cleanup is unconditional.
Unconditionally initializing allows cleanup in case of error-state
to happen fault-free.
nb: patch already submitted upstream to the-tcpdump-group.
FIX
===
--- ./external/bsd/libpcap/dist/gencode.old 2017-02-05
12:34:30.181700021 -0800
+++ ./external/bsd/libpcap/dist/gencode.c 2017-02-05
12:35:03.506099929 -0800
@@ -688,13 +688,13 @@
* If this pcap_t hasn't been activated, it doesn't have a
* link-layer type, so we can't use it.
*/
+ initchunks(&cstate);
if (!p->activated) {
pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
"not-yet-activated pcap_t passed to pcap_compile");
rc = -1;
goto quit;
}
- initchunks(&cstate);
cstate.no_optimize = 0;
cstate.ai = NULL;
cstate.ic.root = NULL;
Home |
Main Index |
Thread Index |
Old Index