]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
login: simplify string handling
authorSami Kerola <kerolasa@iki.fi>
Sun, 21 Jul 2019 18:12:03 +0000 (19:12 +0100)
committerKarel Zak <kzak@redhat.com>
Wed, 24 Jul 2019 09:11:29 +0000 (11:11 +0200)
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
login-utils/login.c

index ce112b54ebcae9482ed056d2e471bab1ad103781..6b9d27e3ef45e316b9d98823a2ee707295e80773 100644 (file)
@@ -1355,10 +1355,7 @@ int main(int argc, char **argv)
 
        /* if the shell field has a space: treat it like a shell script */
        if (strchr(pwd->pw_shell, ' ')) {
-               buff = xmalloc(strlen(pwd->pw_shell) + 6);
-
-               strcpy(buff, "exec ");
-               strcat(buff, pwd->pw_shell);
+               xasprintf(&buff, "exec %s", pwd->pw_shell);
                childArgv[childArgc++] = "/bin/sh";
                childArgv[childArgc++] = "-sh";
                childArgv[childArgc++] = "-c";