summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortedu <tedu@openbsd.org>2014-04-22 20:40:37 +0000
committertedu <tedu@openbsd.org>2014-04-22 20:40:37 +0000
commite7049ca991bab85793c3aade6f514f1cd3d1633c (patch)
tree1d91ddded0955d073d46da1f61baf6d12d754df4
parentnull a pointer to prevent double free. from Dirk Engling (diff)
downloadwireguard-openbsd-e7049ca991bab85793c3aade6f514f1cd3d1633c.tar.xz
wireguard-openbsd-e7049ca991bab85793c3aade6f514f1cd3d1633c.zip
malloc/memset->calloc. with bonus null check. from peter malone.
-rw-r--r--sbin/init/init.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/sbin/init/init.c b/sbin/init/init.c
index b87b2b2a4fd..916a029eced 100644
--- a/sbin/init/init.c
+++ b/sbin/init/init.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: init.c,v 1.49 2014/01/03 22:29:00 millert Exp $ */
+/* $OpenBSD: init.c,v 1.50 2014/04/22 20:40:37 tedu Exp $ */
/* $NetBSD: init.c,v 1.22 1996/05/15 23:29:33 jtc Exp $ */
/*-
@@ -860,8 +860,9 @@ new_session(session_t *sprev, int session_index, struct ttyent *typ)
typ->ty_getty == 0)
return (0);
- sp = (session_t *) malloc(sizeof (session_t));
- memset(sp, 0, sizeof *sp);
+ sp = calloc(1, sizeof (session_t));
+ if (sp == NULL)
+ err(1, "calloc");
sp->se_flags = SE_PRESENT;
sp->se_index = session_index;