summaryrefslogtreecommitdiff
path: root/openbsd-compat/setproctitle.c
diff options
context:
space:
mode:
Diffstat (limited to 'openbsd-compat/setproctitle.c')
-rw-r--r--openbsd-compat/setproctitle.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/openbsd-compat/setproctitle.c b/openbsd-compat/setproctitle.c
index 6e2b19bb4..b511f6649 100644
--- a/openbsd-compat/setproctitle.c
+++ b/openbsd-compat/setproctitle.c
@@ -35,10 +35,13 @@
35 35
36#ifndef HAVE_SETPROCTITLE 36#ifndef HAVE_SETPROCTITLE
37 37
38#include <stdarg.h>
39#include <stdlib.h>
38#include <unistd.h> 40#include <unistd.h>
39#ifdef HAVE_SYS_PSTAT_H 41#ifdef HAVE_SYS_PSTAT_H
40#include <sys/pstat.h> 42#include <sys/pstat.h>
41#endif 43#endif
44#include <string.h>
42 45
43#define SPT_NONE 0 /* don't use it at all */ 46#define SPT_NONE 0 /* don't use it at all */
44#define SPT_PSTAT 1 /* use pstat(PSTAT_SETCMD, ...) */ 47#define SPT_PSTAT 1 /* use pstat(PSTAT_SETCMD, ...) */
@@ -80,7 +83,7 @@ compat_init_setproctitle(int argc, char *argv[])
80 /* Fail if we can't allocate room for the new environment */ 83 /* Fail if we can't allocate room for the new environment */
81 for (i = 0; envp[i] != NULL; i++) 84 for (i = 0; envp[i] != NULL; i++)
82 ; 85 ;
83 if ((environ = malloc(sizeof(*environ) * (i + 1))) == NULL) { 86 if ((environ = calloc(i + 1, sizeof(*environ))) == NULL) {
84 environ = envp; /* put it back */ 87 environ = envp; /* put it back */
85 return; 88 return;
86 } 89 }