npfctl: switch to ecalloc(3). trunk
authorrmind <rmind@NetBSD.org>
Thu, 15 Nov 2012 22:20:27 +0000
branchtrunk
changeset 214531 4a651dc711e2
parent 214530 ab793890cd91
child 214532 9f8e4f0b14d1
npfctl: switch to ecalloc(3).
usr.sbin/npf/npfctl/npf_disassemble.c
usr.sbin/npf/npfctl/npf_extmod.c
usr.sbin/npf/npfctl/npf_ncgen.c
usr.sbin/npf/npfctl/npf_parse.y
usr.sbin/npf/npfctl/npf_scan.l
usr.sbin/npf/npfctl/npf_var.c
usr.sbin/npf/npfctl/npfctl.c
--- a/usr.sbin/npf/npfctl/npf_disassemble.c	Thu Nov 15 19:49:11 2012 +0000
+++ b/usr.sbin/npf/npfctl/npf_disassemble.c	Thu Nov 15 22:20:27 2012 +0000
@@ -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 @@
 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;
--- a/usr.sbin/npf/npfctl/npf_extmod.c	Thu Nov 15 19:49:11 2012 +0000
+++ b/usr.sbin/npf/npfctl/npf_extmod.c	Thu Nov 15 22:20:27 2012 +0000
@@ -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 @@
 		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");
--- a/usr.sbin/npf/npfctl/npf_ncgen.c	Thu Nov 15 19:49:11 2012 +0000
+++ b/usr.sbin/npf/npfctl/npf_ncgen.c	Thu Nov 15 22:20:27 2012 +0000
@@ -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 @@
 nc_ctx_t *
 npfctl_ncgen_create(void)
 {
-	return emalloc(sizeof(nc_ctx_t));
+	return ecalloc(1, sizeof(nc_ctx_t));
 }
 
 /*
--- a/usr.sbin/npf/npfctl/npf_parse.y	Thu Nov 15 19:49:11 2012 +0000
+++ b/usr.sbin/npf/npfctl/npf_parse.y	Thu Nov 15 22:20:27 2012 +0000
@@ -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 @@
 	    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 @@
 	| IPV6ADDR	{ $$ = $1; }
 	;
 
-
 port_range
 	: PORT port		/* just port */
 	{
--- a/usr.sbin/npf/npfctl/npf_scan.l	Thu Nov 15 19:49:11 2012 +0000
+++ b/usr.sbin/npf/npfctl/npf_scan.l	Thu Nov 15 22:20:27 2012 +0000
@@ -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 @@
 "="			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);
--- a/usr.sbin/npf/npfctl/npf_var.c	Thu Nov 15 19:49:11 2012 +0000
+++ b/usr.sbin/npf/npfctl/npf_var.c	Thu Nov 15 22:20:27 2012 +0000
@@ -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 @@
 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 @@
 		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);
 
--- a/usr.sbin/npf/npfctl/npfctl.c	Thu Nov 15 19:49:11 2012 +0000
+++ b/usr.sbin/npf/npfctl/npfctl.c	Thu Nov 15 22:20:27 2012 +0000
@@ -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 @@
 		{ -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 @@
 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 @@
 	}
 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)) {