summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2018-11-25 15:31:13 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2018-11-25 15:31:13 +0000
commit52f7637d0423eb91835d15a8249952994ccd9714 (patch)
tree08c16945c661166e8d10d786b573b1b90a5564fc
parent0f2fb00f10335dbc222485a8051a53dbff545603 (diff)
malloc(n) + bzero is better done as calloc(1,n)
-rw-r--r--usr.sbin/bgpd/pftable.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/usr.sbin/bgpd/pftable.c b/usr.sbin/bgpd/pftable.c
index 9766f1edfc3..418af987204 100644
--- a/usr.sbin/bgpd/pftable.c
+++ b/usr.sbin/bgpd/pftable.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pftable.c,v 1.11 2018/09/20 11:06:04 benno Exp $ */
+/* $OpenBSD: pftable.c,v 1.12 2018/11/25 15:31:12 deraadt Exp $ */
/*
* Copyright (c) 2004 Damien Miller <djm@openbsd.org>
@@ -137,12 +137,11 @@ pftable_add(const char *name)
if (strcmp(pft->name, name) == 0)
return (0);
- if ((pft = malloc(sizeof(*pft))) == NULL) {
+ if ((pft = calloc(1, sizeof(*pft))) == NULL) {
log_warn("pftable malloc");
return (-1);
}
- bzero(pft, sizeof(*pft));
if (strlcpy(pft->name, name, sizeof(pft->name)) >= sizeof(pft->name)) {
log_warn("pf_table name too long");
free(pft);