login: use calloc() when memory needs to be cleared

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This commit is contained in:
Sami Kerola 2020-11-13 22:58:17 +00:00
parent 0da0a5ed3b
commit 5941a0db06
No known key found for this signature in database
GPG Key ID: 0D46FEF7E61DBB46
1 changed files with 2 additions and 4 deletions

View File

@ -1159,10 +1159,8 @@ static void init_environ(struct login_context *cxt)
termenv = xstrdup(termenv);
/* destroy environment unless user has requested preservation (-p) */
if (!cxt->keep_env) {
environ = xmalloc(sizeof(char *));
memset(environ, 0, sizeof(char *));
}
if (!cxt->keep_env)
environ = xcalloc(1, sizeof(char *));
xsetenv("HOME", pwd->pw_dir, 0); /* legal to override */
xsetenv("USER", pwd->pw_name, 1);