Module Name: src Committed By: rmind Date: Thu Nov 15 22:20:27 UTC 2012
Modified Files: src/usr.sbin/npf/npfctl: npf_disassemble.c npf_extmod.c npf_ncgen.c npf_parse.y npf_scan.l npf_var.c npfctl.c Log Message: npfctl: switch to ecalloc(3). To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/usr.sbin/npf/npfctl/npf_disassemble.c cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/npf/npfctl/npf_extmod.c cvs rdiff -u -r1.14 -r1.15 src/usr.sbin/npf/npfctl/npf_ncgen.c cvs rdiff -u -r1.15 -r1.16 src/usr.sbin/npf/npfctl/npf_parse.y cvs rdiff -u -r1.7 -r1.8 src/usr.sbin/npf/npfctl/npf_scan.l cvs rdiff -u -r1.6 -r1.7 src/usr.sbin/npf/npfctl/npf_var.c cvs rdiff -u -r1.23 -r1.24 src/usr.sbin/npf/npfctl/npfctl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.sbin/npf/npfctl/npf_disassemble.c diff -u src/usr.sbin/npf/npfctl/npf_disassemble.c:1.11 src/usr.sbin/npf/npfctl/npf_disassemble.c:1.12 --- src/usr.sbin/npf/npfctl/npf_disassemble.c:1.11 Mon Nov 5 23:47:12 2012 +++ src/usr.sbin/npf/npfctl/npf_disassemble.c Thu Nov 15 22:20:27 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: npf_disassemble.c,v 1.11 2012/11/05 23:47:12 rmind Exp $ */ +/* $NetBSD: npf_disassemble.c,v 1.12 2012/11/15 22:20:27 rmind Exp $ */ /*- * Copyright (c) 2012 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ * FIXME: config generation should be redesigned.. */ #include <sys/cdefs.h> -__RCSID("$NetBSD: npf_disassemble.c,v 1.11 2012/11/05 23:47:12 rmind Exp $"); +__RCSID("$NetBSD: npf_disassemble.c,v 1.12 2012/11/15 22:20:27 rmind Exp $"); #include <stdio.h> #include <stdlib.h> @@ -370,7 +370,7 @@ npfctl_ncode_operand(nc_inf_t *ni, char nc_inf_t * npfctl_ncode_disinf(FILE *fp) { - nc_inf_t *ni = emalloc(sizeof(nc_inf_t)); + nc_inf_t *ni = ecalloc(1, sizeof(nc_inf_t)); memset(ni, 0, sizeof(nc_inf_t)); ni->ni_fp = fp; Index: src/usr.sbin/npf/npfctl/npf_extmod.c diff -u src/usr.sbin/npf/npfctl/npf_extmod.c:1.2 src/usr.sbin/npf/npfctl/npf_extmod.c:1.3 --- src/usr.sbin/npf/npfctl/npf_extmod.c:1.2 Mon Nov 5 23:47:12 2012 +++ src/usr.sbin/npf/npfctl/npf_extmod.c Thu Nov 15 22:20:27 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: npf_extmod.c,v 1.2 2012/11/05 23:47:12 rmind Exp $ */ +/* $NetBSD: npf_extmod.c,v 1.3 2012/11/15 22:20:27 rmind Exp $ */ /*- * Copyright (c) 2012 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ */ #include <sys/cdefs.h> -__RCSID("$NetBSD: npf_extmod.c,v 1.2 2012/11/05 23:47:12 rmind Exp $"); +__RCSID("$NetBSD: npf_extmod.c,v 1.3 2012/11/15 22:20:27 rmind Exp $"); #include <stdlib.h> #include <inttypes.h> @@ -81,7 +81,7 @@ npf_extmod_load(const char *name) errx(EXIT_FAILURE, "dlopen: %s", dlerror()); } - ext = emalloc(sizeof(npf_extmod_t)); + ext = ecalloc(1, sizeof(npf_extmod_t)); ext->name = estrdup(name); ext->init = npf_extmod_sym(handle, name, "init"); ext->cons = npf_extmod_sym(handle, name, "construct"); Index: src/usr.sbin/npf/npfctl/npf_ncgen.c diff -u src/usr.sbin/npf/npfctl/npf_ncgen.c:1.14 src/usr.sbin/npf/npfctl/npf_ncgen.c:1.15 --- src/usr.sbin/npf/npfctl/npf_ncgen.c:1.14 Mon Nov 5 23:47:12 2012 +++ src/usr.sbin/npf/npfctl/npf_ncgen.c Thu Nov 15 22:20:27 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: npf_ncgen.c,v 1.14 2012/11/05 23:47:12 rmind Exp $ */ +/* $NetBSD: npf_ncgen.c,v 1.15 2012/11/15 22:20:27 rmind Exp $ */ /*- * Copyright (c) 2009-2012 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ */ #include <sys/cdefs.h> -__RCSID("$NetBSD: npf_ncgen.c,v 1.14 2012/11/05 23:47:12 rmind Exp $"); +__RCSID("$NetBSD: npf_ncgen.c,v 1.15 2012/11/15 22:20:27 rmind Exp $"); #include <stdlib.h> #include <stddef.h> @@ -145,7 +145,7 @@ npfctl_ncgen_addjmp(nc_ctx_t *ctx, uint3 nc_ctx_t * npfctl_ncgen_create(void) { - return emalloc(sizeof(nc_ctx_t)); + return ecalloc(1, sizeof(nc_ctx_t)); } /* Index: src/usr.sbin/npf/npfctl/npf_parse.y diff -u src/usr.sbin/npf/npfctl/npf_parse.y:1.15 src/usr.sbin/npf/npfctl/npf_parse.y:1.16 --- src/usr.sbin/npf/npfctl/npf_parse.y:1.15 Mon Nov 5 23:47:12 2012 +++ src/usr.sbin/npf/npfctl/npf_parse.y Thu Nov 15 22:20:27 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: npf_parse.y,v 1.15 2012/11/05 23:47:12 rmind Exp $ */ +/* $NetBSD: npf_parse.y,v 1.16 2012/11/15 22:20:27 rmind Exp $ */ /*- * Copyright (c) 2011-2012 The NetBSD Foundation, Inc. @@ -66,7 +66,7 @@ yyerror(const char *fmt, ...) yylineno - (int)eol, yycolumn, msg); if (!eol) { size_t len = strlen(context); - char *dst = emalloc(len * 4 + 1); + char *dst = ecalloc(1, len * 4 + 1); strvisx(dst, context, len, VIS_WHITE|VIS_CSTYLE); fprintf(stderr, " near '%s'", dst); @@ -610,7 +610,6 @@ addr | IPV6ADDR { $$ = $1; } ; - port_range : PORT port /* just port */ { Index: src/usr.sbin/npf/npfctl/npf_scan.l diff -u src/usr.sbin/npf/npfctl/npf_scan.l:1.7 src/usr.sbin/npf/npfctl/npf_scan.l:1.8 --- src/usr.sbin/npf/npfctl/npf_scan.l:1.7 Mon Nov 5 23:47:12 2012 +++ src/usr.sbin/npf/npfctl/npf_scan.l Thu Nov 15 22:20:27 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: npf_scan.l,v 1.7 2012/11/05 23:47:12 rmind Exp $ */ +/* $NetBSD: npf_scan.l,v 1.8 2012/11/15 22:20:27 rmind Exp $ */ /*- * Copyright (c) 2011-2012 The NetBSD Foundation, Inc. @@ -109,7 +109,7 @@ any return ANY; "=" return EQ; "0x"[0-9a-fA-F]+ { - char *endp, *buf = emalloc(yyleng + 1); + char *endp, *buf = ecalloc(1, yyleng + 1); buf[yyleng] = 0; yylval.num = strtoul(buf+2, &endp, 16); free(buf); Index: src/usr.sbin/npf/npfctl/npf_var.c diff -u src/usr.sbin/npf/npfctl/npf_var.c:1.6 src/usr.sbin/npf/npfctl/npf_var.c:1.7 --- src/usr.sbin/npf/npfctl/npf_var.c:1.6 Mon Nov 5 23:47:12 2012 +++ src/usr.sbin/npf/npfctl/npf_var.c Thu Nov 15 22:20:27 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: npf_var.c,v 1.6 2012/11/05 23:47:12 rmind Exp $ */ +/* $NetBSD: npf_var.c,v 1.7 2012/11/15 22:20:27 rmind Exp $ */ /*- * Copyright (c) 2011-2012 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__RCSID("$NetBSD: npf_var.c,v 1.6 2012/11/05 23:47:12 rmind Exp $"); +__RCSID("$NetBSD: npf_var.c,v 1.7 2012/11/15 22:20:27 rmind Exp $"); #include <stdlib.h> #include <string.h> @@ -60,7 +60,7 @@ static size_t var_num = 0; npfvar_t * npfvar_create(const char *name) { - npfvar_t *vp = emalloc(sizeof(*vp)); + npfvar_t *vp = ecalloc(1, sizeof(*vp)); vp->v_key = estrdup(name); var_num++; return vp; @@ -104,8 +104,8 @@ npfvar_add_element(npfvar_t *vp, int typ return NULL; } vp->v_count++; - el = emalloc(sizeof(*el)); - el->e_data = emalloc(len); + el = ecalloc(1, sizeof(*el)); + el->e_data = ecalloc(1, len); el->e_type = type; memcpy(el->e_data, data, len); Index: src/usr.sbin/npf/npfctl/npfctl.c diff -u src/usr.sbin/npf/npfctl/npfctl.c:1.23 src/usr.sbin/npf/npfctl/npfctl.c:1.24 --- src/usr.sbin/npf/npfctl/npfctl.c:1.23 Mon Nov 5 23:47:12 2012 +++ src/usr.sbin/npf/npfctl/npfctl.c Thu Nov 15 22:20:27 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: npfctl.c,v 1.23 2012/11/05 23:47:12 rmind Exp $ */ +/* $NetBSD: npfctl.c,v 1.24 2012/11/15 22:20:27 rmind Exp $ */ /*- * Copyright (c) 2009-2012 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__RCSID("$NetBSD: npfctl.c,v 1.23 2012/11/05 23:47:12 rmind Exp $"); +__RCSID("$NetBSD: npfctl.c,v 1.24 2012/11/15 22:20:27 rmind Exp $"); #include <sys/ioctl.h> #include <sys/stat.h> @@ -163,7 +163,7 @@ npfctl_print_stats(int fd) { -1, "Other" }, { NPF_STAT_ERROR, "unexpected errors" }, }; - uint64_t *st = emalloc(NPF_STATS_SIZE); + uint64_t *st = ecalloc(1, NPF_STATS_SIZE); if (ioctl(fd, IOC_NPF_STATS, &st) != 0) { err(EXIT_FAILURE, "ioctl(IOC_NPF_STATS)"); @@ -213,7 +213,7 @@ char * npfctl_print_addrmask(int alen, npf_addr_t *addr, npf_netmask_t mask) { struct sockaddr_storage ss; - char *buf = emalloc(64); + char *buf = ecalloc(1, 64); int len; switch (alen) { @@ -285,7 +285,7 @@ npfctl_table(int fd, int argc, char **ar } again: if (nct.nct_action == NPF_IOCTL_TBLENT_LIST) { - nct.nct_data.buf.buf = emalloc(buflen); + nct.nct_data.buf.buf = ecalloc(1, buflen); nct.nct_data.buf.len = buflen; } else { if (!npfctl_parse_cidr(arg, &fam, &alen)) {