summaryrefslogtreecommitdiffhomepage
path: root/shell/hush.c
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2009-10-18 01:11:45 -0400
committerMike Frysinger <vapier@gentoo.org>2009-10-18 01:15:36 -0400
commit28736c36ca6a73864324296117ce26c9a23066dd (patch)
tree932f02ded50c8df7db9a7eea3063c2ed6c841fc1 /shell/hush.c
parent69d9edc6f8387ed0ec4742a5de895b22b3910818 (diff)
hush: handle empty execs
Sometimes variable expansions yield empty strings, and if they happen to be a command someone wants to run like `$foo`, then hush currently segfaults. So handle `` and $(). Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'shell/hush.c')
-rw-r--r--shell/hush.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/shell/hush.c b/shell/hush.c
index 2d333d731..1d2826d9a 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -3895,6 +3895,12 @@ static NOINLINE int run_pipe(struct pipe *pi)
argv_expanded = expand_strvec_to_strvec(argv + command->assignment_cnt);
}
+ /* if someone gives us an empty string: ``, $(), ... */
+ if (!argv_expanded[0]) {
+ debug_leave();
+ return 0;
+ }
+
x = find_builtin(argv_expanded[0]);
#if ENABLE_HUSH_FUNCTIONS
funcp = NULL;