Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Command hashing/autocd bug & possible fixes
- X-seq: zsh-workers 44141
- From: Peter Stephenson <p.stephenson@xxxxxxxxxxx>
- To: <zsh-workers@xxxxxxx>
- Subject: Re: Command hashing/autocd bug & possible fixes
- Date: Mon, 18 Mar 2019 10:01:49 +0000
- Cms-type: 201P
- Dkim-filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20190318100151euoutp0229ee6e83b3536e4388caeff220480f79~NBVWGBFkv2138021380euoutp02y
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1552903311; bh=6aIQQmVPobN/g78LlaEKxrWMFzx3w4TyHxfYMPOrppk=; h=Subject:From:To:Date:In-Reply-To:References:From; b=gMtd41iv7QZSmk/qxTxQG5VGDCTaahuAbPBWS6KN6jUIAy6twiSL4Tt4LNTkl2Z2g TVcFMXDM70R3WTWMNTXnDzt2RITU2Qhhh5ewiqrqqmPuFRhjc+T8MTU3hvnEeLP7vP CvJ2ZSO7wo9O+X1sbz+0R7B0rkZP4Cru/hE5D4AE=
- In-reply-to: <CAKiz1a8Y9HRpBfCF3sL_bvVHJZoAie9OOwcoqANy5i9DviA_cQ@mail.gmail.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <CGME20190316200339epcas3p2370800b4409cedfc025ef1c972334aa7@epcas3p2.samsung.com> <CAKiz1a8Y9HRpBfCF3sL_bvVHJZoAie9OOwcoqANy5i9DviA_cQ@mail.gmail.com>
On Sat, 2019-03-16 at 16:01 -0400, Charles Blake wrote:
> Another possible fix might be to try to stop hashcmd from entering
> keys with a leading '/' (or accept an allowRooted parameter). The
> easiest way to do that..
>
> diff --git a/Src/exec.c b/Src/exec.c
> index 042ba065a..79ef83c1e 100644
> --- a/Src/exec.c
> +++ b/Src/exec.c
> @@ -940,6 +940,8 @@ hashcmd(char *arg0, char **pp)
> char *s, buf[PATH_MAX+1];
> char **pq;
>
> + if (*arg0 == '/')
> + return NULL;
> for (; *pp; pp++)
> if (**pp == '/') {
> s = buf;
This certainly looks plausible. I can't offhand think of a reason why a
hashed command would begin with a "/"; it's just asking for trouble.
We've been confusingly lax about this sort of thing in other places ---
for example, autoload of a function beginning with a "/" used to do path
look up under $fpath, though for a couple of years now has been treated
as an absolute path.
Unless anyone comes up with a counterexample I think I'll put this in.
Thanks for the work.
pws
Messages sorted by:
Reverse Date,
Date,
Thread,
Author