Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/external/bsd/libpcap/dist PR lib/51952: Brad Harder: Apply u...



details:   https://anonhg.NetBSD.org/src/rev/850c5980ffc1
branches:  trunk
changeset: 826034:850c5980ffc1
user:      ginsbach <ginsbach%NetBSD.org@localhost>
date:      Sat Aug 12 00:43:25 2017 +0000

description:
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

diffstat:

 external/bsd/libpcap/dist/gencode.c |  24 ++++++++++++------------
 1 files changed, 12 insertions(+), 12 deletions(-)

diffs (60 lines):

diff -r a6023362944a -r 850c5980ffc1 external/bsd/libpcap/dist/gencode.c
--- a/external/bsd/libpcap/dist/gencode.c       Fri Aug 11 22:59:05 2017 +0000
+++ b/external/bsd/libpcap/dist/gencode.c       Sat Aug 12 00:43:25 2017 +0000
@@ -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 @@
 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 @@
        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 @@
        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;



Home | Main Index | Thread Index | Old Index