builtin: describe_command - fix incorrect path
commitf19f3b398a2e947148a646096de94b77c73bb55d
authorHarald van Dijk <harald@gigawatt.nl>
Fri, 26 May 2017 07:59:44 +0000 (26 09:59 +0200)
committerHerbert Xu <herbert@gondor.apana.org.au>
Sat, 10 Mar 2018 08:01:42 +0000 (10 16:01 +0800)
treebf4db378c7dc2ab18b3490e59d33def954933e05
parent53dab360a1e0dddcfd83c6cbfc9f720f5e233550
builtin: describe_command - fix incorrect path

Hi,

On 26/05/17 09:04, Youfu Zhang wrote:
> $ PATH=/extra/path:/usr/sbin:/usr/bin:/sbin:/bin \
>> 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 (core dumped)
>
> 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.

True, but only when a path is passed in. If the default path is used,
looking up in the hash table is correct, and printing tracked aliases is
intentional.

If it's desirable to drop that feature, then it should be dropped
completely, code shouldn't be left in that can no longer be used. But
it's possible to keep it working: how about this instead?

Signed-off-by: Harald van Dijk <harald@gigawatt.nl>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
src/exec.c