zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.stephenson@samsung.com>
To: <zsh-workers@zsh.org>
Subject: Re: Command hashing/autocd bug & possible fixes
Date: Mon, 18 Mar 2019 10:01:49 +0000	[thread overview]
Message-ID: <1552903309.5658.4.camel@samsung.com> (raw)
In-Reply-To: <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



  reply	other threads:[~2019-03-18 10:02 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20190316200339epcas3p2370800b4409cedfc025ef1c972334aa7@epcas3p2.samsung.com>
2019-03-16 20:01 ` Charles Blake
2019-03-18 10:01   ` Peter Stephenson [this message]
2019-03-18 21:20     ` Charles Blake

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1552903309.5658.4.camel@samsung.com \
    --to=p.stephenson@samsung.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).