Module Name:    src
Committed By:   snj
Date:           Mon Aug 14 23:56:35 UTC 2017

Modified Files:
        src/external/bsd/libpcap/dist [netbsd-8]: gencode.c

Log Message:
Pull up following revision(s) (requested by ginsbach in ticket #209):
        external/bsd/libpcap/dist/gencode.c: revision 1.10
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.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.9.4.1 src/external/bsd/libpcap/dist/gencode.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/bsd/libpcap/dist/gencode.c
diff -u src/external/bsd/libpcap/dist/gencode.c:1.9 src/external/bsd/libpcap/dist/gencode.c:1.9.4.1
--- src/external/bsd/libpcap/dist/gencode.c:1.9	Tue Jan 24 22:29:28 2017
+++ src/external/bsd/libpcap/dist/gencode.c	Mon Aug 14 23:56:35 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: gencode.c,v 1.9 2017/01/24 22:29:28 christos Exp $	*/
+/*	$NetBSD: gencode.c,v 1.9.4.1 2017/08/14 23:56:35 snj 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.9.4.1 2017/08/14 23:56:35 snj 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_progr
 	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_progr
 	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;

Reply via email to