From: millert Date: Wed, 14 Jan 2015 18:28:15 +0000 (+0000) Subject: Use reallocarray() instead of calloc() when making a copy of the X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=c1606dc636c54bf80935e3e34b06ec5630e94475;p=openbsd Use reallocarray() instead of calloc() when making a copy of the environment. We already explicitly NULL terminate the array. --- diff --git a/usr.sbin/cron/env.c b/usr.sbin/cron/env.c index 8fa993ac447..ff9f1c9251d 100644 --- a/usr.sbin/cron/env.c +++ b/usr.sbin/cron/env.c @@ -1,4 +1,4 @@ -/* $OpenBSD: env.c,v 1.24 2014/10/08 04:20:57 deraadt Exp $ */ +/* $OpenBSD: env.c,v 1.25 2015/01/14 18:28:15 millert Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * All rights reserved @@ -25,7 +25,7 @@ char ** env_init(void) { - char **p = (char **) malloc(sizeof(char **)); + char **p = malloc(sizeof(char **)); if (p != NULL) p[0] = NULL; @@ -48,7 +48,7 @@ env_copy(char **envp) { for (count = 0; envp[count] != NULL; count++) continue; - p = (char **) calloc(count+1, sizeof(char *)); /* 1 for the NULL */ + p = reallocarray(NULL, count+1, sizeof(char *)); /* 1 for the NULL */ if (p != NULL) { for (i = 0; i < count; i++) if ((p[i] = strdup(envp[i])) == NULL) {