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>
This commit is contained in:
parent
69d9edc6f8
commit
28736c36ca
@ -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;
|
||||
|
14
shell/hush_test/hush-psubst/emptytick.right
Normal file
14
shell/hush_test/hush-psubst/emptytick.right
Normal file
@ -0,0 +1,14 @@
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
16
shell/hush_test/hush-psubst/emptytick.tests
Executable file
16
shell/hush_test/hush-psubst/emptytick.tests
Executable file
@ -0,0 +1,16 @@
|
||||
true; ``; echo $?
|
||||
false; ``; echo $?
|
||||
true; `""`; echo $?
|
||||
false; `""`; echo $?
|
||||
true; ` `; echo $?
|
||||
false; ` `; echo $?
|
||||
|
||||
true; $(); echo $?
|
||||
false; $(); echo $?
|
||||
true; $(""); echo $?
|
||||
false; $(""); echo $?
|
||||
true; $( ); echo $?
|
||||
false; $( ); echo $?
|
||||
|
||||
true; exec ''; echo $?
|
||||
false; exec ''; echo $?
|
Loading…
Reference in New Issue
Block a user