]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
exec_shell: prevent ".: applet not found" error when SHELL env is not set.
authorosexp2000 <osexp2000@gmail.com>
Mon, 25 Jun 2018 01:34:31 +0000 (10:34 +0900)
committerKarel Zak <kzak@redhat.com>
Wed, 11 Jul 2018 14:12:21 +0000 (16:12 +0200)
When SHELL env is not set, it cause xstrdup(NULL) be executed, and result in weird error message ".: applet not found" instead of /bin/sh being used.

lib/exec_shell.c

index 49b7df5bfde93c039ae14d0f0f0a7f63d460cff1..18798ebe4e2ffd73f53ea7d50e55a64aa5488ffc 100644 (file)
 void __attribute__((__noreturn__)) exec_shell(void)
 {
        const char *shell = getenv("SHELL");
-       char *shellc = xstrdup(shell);
+       char *shellc;
        const char *shell_basename;
        char *arg0;
 
        if (!shell)
                shell = DEFAULT_SHELL;
 
+       shellc = xstrdup(shell);
        shell_basename = basename(shellc);
        arg0 = xmalloc(strlen(shell_basename) + 2);
        arg0[0] = '-';