PR lib/51952: Brad Harder: Apply upstream ada959c9
[From upstream tcpdump] In pcap_compile(), first check whether the pcap_t is activated. Before we allocate or otherwise set up anything, check whether the pcap_t is activated, and set the error message string and return -1 if it's not. That way, we don't go through the cleanup code in that code path - there's nothing to clean up. Fixes the issue in GitHub pull request #552. XXX: pullup-8
This commit is contained in:
parent
0c7c75bc0c
commit
7ab23dde59
24
external/bsd/libpcap/dist/gencode.c
vendored
24
external/bsd/libpcap/dist/gencode.c
vendored
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: gencode.c,v 1.9 2017/01/24 22:29:28 christos Exp $ */
|
||||
/* $NetBSD: gencode.c,v 1.10 2017/08/12 00:43:25 ginsbach Exp $ */
|
||||
|
||||
/*#define CHASE_CHAIN*/
|
||||
/*
|
||||
@ -23,7 +23,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__RCSID("$NetBSD: gencode.c,v 1.9 2017/01/24 22:29:28 christos Exp $");
|
||||
__RCSID("$NetBSD: gencode.c,v 1.10 2017/08/12 00:43:25 ginsbach Exp $");
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
@ -669,6 +669,9 @@ int
|
||||
pcap_compile(pcap_t *p, struct bpf_program *program,
|
||||
const char *buf, int optimize, bpf_u_int32 mask)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
static int done = 0;
|
||||
#endif
|
||||
compiler_state_t cstate;
|
||||
const char * volatile xbuf = buf;
|
||||
yyscan_t scanner = NULL;
|
||||
@ -676,14 +679,6 @@ pcap_compile(pcap_t *p, struct bpf_program *program,
|
||||
u_int len;
|
||||
int rc;
|
||||
|
||||
#ifdef _WIN32
|
||||
static int done = 0;
|
||||
|
||||
if (!done)
|
||||
pcap_wsockinit();
|
||||
done = 1;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* If this pcap_t hasn't been activated, it doesn't have a
|
||||
* link-layer type, so we can't use it.
|
||||
@ -691,9 +686,14 @@ pcap_compile(pcap_t *p, struct bpf_program *program,
|
||||
if (!p->activated) {
|
||||
pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
|
||||
"not-yet-activated pcap_t passed to pcap_compile");
|
||||
rc = -1;
|
||||
goto quit;
|
||||
return -1;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
if (!done)
|
||||
pcap_wsockinit();
|
||||
done = 1;
|
||||
#endif
|
||||
initchunks(&cstate);
|
||||
cstate.no_optimize = 0;
|
||||
cstate.ai = NULL;
|
||||
|
Loading…
Reference in New Issue
Block a user