[PATCH] ash: fix incorrect path in describe_command
Denys Vlasenko
vda.linux at googlemail.com
Fri May 26 15:38:01 UTC 2017
On Fri, May 26, 2017 at 9:31 AM, Youfu Zhang <zhangyoufu at gmail.com> wrote:
> $ PATH=/extra/path:/usr/sbin:/usr/bin:/sbin:/bin \
>> busybox sh -xc 'command -V ls; command -V ls; command -Vp ls; command -vp ls'
> + command -V ls
> ls is /bin/ls
> + command -V ls
> ls is a tracked alias for /bin/ls
> + command -Vp ls
> ls is a tracked alias for (null)
> + command -vp ls
> Segmentation fault
>
> describe_command should respect `path' argument. Looking up in the hash table
> may gives incorrect index in entry.u.index and finally causes incorrect output
> or SIGSEGV.
>
> Signed-off-by: Youfu Zhang <zhangyoufu at gmail.com>
> ---
> shell/ash.c | 11 ++---------
> 1 file changed, 2 insertions(+), 9 deletions(-)
>
> diff --git a/shell/ash.c b/shell/ash.c
> index 60c8ffe..1ff9d12 100644
> --- a/shell/ash.c
> +++ b/shell/ash.c
> @@ -8193,15 +8193,8 @@ describe_command(char *command, const char *path, int describe_command_verbose)
> goto out;
> }
> #endif
> - /* Then check if it is a tracked alias */
> - cmdp = cmdlookup(command, 0);
> - if (cmdp != NULL) {
> - entry.cmdtype = cmdp->cmdtype;
> - entry.u = cmdp->param;
> - } else {
> - /* Finally use brute force */
> - find_command(command, &entry, DO_ABS, path);
> - }
> + /* Brute force */
> + find_command(command, &entry, DO_ABS, path);
>
> switch (entry.cmdtype) {
> case CMDNORMAL: {
cc1: warnings being treated as errors
shell/ash.c: In function 'describe_command':
shell/ash.c:8212: error: 'cmdp' may be used uninitialized in this function
Applied with a fix.
More information about the busybox
mailing list