]> The Tcpdump Group git mirrors - libpcap/blobdiff - optimize.c
In the open request, reject capture sources that are URLs.
[libpcap] / optimize.c
index e676df9fe8227fae740c671075b8bd6da994a877..283a6de30fa3f6b99f576cc043a68b98a6722e34 100644 (file)
@@ -2069,7 +2069,7 @@ opt_error(opt_state_t *opt_state, const char *fmt, ...)
 
        if (opt_state->errbuf != NULL) {
                va_start(ap, fmt);
-               (void)pcap_vsnprintf(opt_state->errbuf,
+               (void)vsnprintf(opt_state->errbuf,
                    PCAP_ERRBUF_SIZE, fmt, ap);
                va_end(ap);
        }
@@ -2182,7 +2182,6 @@ opt_init(opt_state_t *opt_state, struct icode *ic)
        opt_state->n_edges = 2 * opt_state->n_blocks;
        opt_state->edges = (struct edge **)calloc(opt_state->n_edges, sizeof(*opt_state->edges));
        if (opt_state->edges == NULL) {
-               free(opt_state->blocks);
                opt_error(opt_state, "malloc");
        }
 
@@ -2191,8 +2190,6 @@ opt_init(opt_state_t *opt_state, struct icode *ic)
         */
        opt_state->levels = (struct block **)calloc(opt_state->n_blocks, sizeof(*opt_state->levels));
        if (opt_state->levels == NULL) {
-               free(opt_state->edges);
-               free(opt_state->blocks);
                opt_error(opt_state, "malloc");
        }
 
@@ -2203,9 +2200,6 @@ opt_init(opt_state_t *opt_state, struct icode *ic)
        opt_state->space = (bpf_u_int32 *)malloc(2 * opt_state->n_blocks * opt_state->nodewords * sizeof(*opt_state->space)
                                 + opt_state->n_edges * opt_state->edgewords * sizeof(*opt_state->space));
        if (opt_state->space == NULL) {
-               free(opt_state->levels);
-               free(opt_state->edges);
-               free(opt_state->blocks);
                opt_error(opt_state, "malloc");
        }
        p = opt_state->space;
@@ -2245,19 +2239,10 @@ opt_init(opt_state_t *opt_state, struct icode *ic)
        opt_state->maxval = 3 * max_stmts;
        opt_state->vmap = (struct vmapinfo *)calloc(opt_state->maxval, sizeof(*opt_state->vmap));
        if (opt_state->vmap == NULL) {
-               free(opt_state->space);
-               free(opt_state->levels);
-               free(opt_state->edges);
-               free(opt_state->blocks);
                opt_error(opt_state, "malloc");
        }
        opt_state->vnode_base = (struct valnode *)calloc(opt_state->maxval, sizeof(*opt_state->vnode_base));
        if (opt_state->vnode_base == NULL) {
-               free(opt_state->vmap);
-               free(opt_state->space);
-               free(opt_state->levels);
-               free(opt_state->edges);
-               free(opt_state->blocks);
                opt_error(opt_state, "malloc");
        }
 }
@@ -2477,7 +2462,7 @@ filled:
  * done with the filter program.  See the pcap man page.
  */
 struct bpf_insn *
-icode_to_fcode(struct icode *ic, struct block *root, u_int *lenp, 
+icode_to_fcode(struct icode *ic, struct block *root, u_int *lenp,
     char *errbuf)
 {
        u_int n;
@@ -2501,7 +2486,7 @@ icode_to_fcode(struct icode *ic, struct block *root, u_int *lenp,
 
            fp = (struct bpf_insn *)malloc(sizeof(*fp) * n);
            if (fp == NULL) {
-               (void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
+               (void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
                    "malloc");
                free(fp);
                return NULL;
@@ -2528,7 +2513,7 @@ conv_error(conv_state_t *conv_state, const char *fmt, ...)
        va_list ap;
 
        va_start(ap, fmt);
-       (void)pcap_vsnprintf(conv_state->errbuf,
+       (void)vsnprintf(conv_state->errbuf,
            PCAP_ERRBUF_SIZE, fmt, ap);
        va_end(ap);
        longjmp(conv_state->top_ctx, 1);
@@ -2552,7 +2537,7 @@ install_bpf_program(pcap_t *p, struct bpf_program *fp)
         * Validate the program.
         */
        if (!pcap_validate_filter(fp->bf_insns, fp->bf_len)) {
-               pcap_snprintf(p->errbuf, sizeof(p->errbuf),
+               snprintf(p->errbuf, sizeof(p->errbuf),
                        "BPF program is not valid");
                return (-1);
        }