]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
login: use calloc() when memory needs to be cleared
authorSami Kerola <kerolasa@iki.fi>
Fri, 13 Nov 2020 22:58:17 +0000 (22:58 +0000)
committerSami Kerola <kerolasa@iki.fi>
Thu, 3 Dec 2020 20:07:29 +0000 (20:07 +0000)
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
login-utils/login.c

index 4f0296c422f2c22dda4a243130055c174ff15e26..b03808a5c2e16acf1a736c09abb0af5d6a26af87 100644 (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);