summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorosexp20002018-06-25 03:34:31 +0200
committerosexp20002018-06-25 03:34:31 +0200
commit82adb91f6eff659474007cb776ef0091c95aac1f (patch)
tree9e378a78f81fb19301b256c11a1d7471f5d91dd7 /lib
parentdocs: update TODO (diff)
downloadkernel-qcow2-util-linux-82adb91f6eff659474007cb776ef0091c95aac1f.tar.gz
kernel-qcow2-util-linux-82adb91f6eff659474007cb776ef0091c95aac1f.tar.xz
kernel-qcow2-util-linux-82adb91f6eff659474007cb776ef0091c95aac1f.zip
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.
Diffstat (limited to 'lib')
-rw-r--r--lib/exec_shell.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/exec_shell.c b/lib/exec_shell.c
index 49b7df5bf..18798ebe4 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] = '-';