From: osexp2000 Date: Mon, 25 Jun 2018 01:34:31 +0000 (+0900) Subject: exec_shell: prevent ".: applet not found" error when SHELL env is not set. X-Git-Tag: v2.32.1~9 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=dc70eb940a7976011c2d61c682b18eee4804f705;p=thirdparty%2Futil-linux.git exec_shell: prevent ".: applet not found" error when SHELL env is not set. 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. --- diff --git a/lib/exec_shell.c b/lib/exec_shell.c index 49b7df5bfd..18798ebe4e 100644 --- a/lib/exec_shell.c +++ b/lib/exec_shell.c @@ -33,13 +33,14 @@ 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] = '-';