From 52f7637d0423eb91835d15a8249952994ccd9714 Mon Sep 17 00:00:00 2001 From: Theo de Raadt Date: Sun, 25 Nov 2018 15:31:13 +0000 Subject: malloc(n) + bzero is better done as calloc(1,n) --- usr.sbin/bgpd/pftable.c | 5 ++--- 1 file 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 @@ -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); -- cgit v1.2.3