zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: mason@primenet.com.au, zsh-workers@sunsite.dk
Subject: Re: Obscure overflow with very long path; completion
Date: Sat, 07 May 2005 16:23:05 +0000	[thread overview]
Message-ID: <1050507162306.ZM1184@candle.brasslantern.com> (raw)
In-Reply-To: <slrnd7lrgo.32l.mason@g.primenet.com.au>

On May 6,  4:10am, Geoff Wing wrote:
} Subject: Re: Obscure overflow with very long path; completion
}
} These two in utils.c:
}    static char xbuf[PATH_MAX*2];
} and
}    char xbuf2[PATH_MAX*2], ...
} are insufficient because the path is over twice the allowed PATH_MAX
} (1024) on my machine.

Try this patch?

My fear is that this is going to lead to slowness such as that fixed by
the recent patches to the globbing code, but hopefully this isn't called
quite as often.

Index: Src/utils.c
===================================================================
retrieving revision 1.23
diff -c -r1.23 utils.c
--- Src/utils.c	14 Apr 2005 04:33:51 -0000	1.23
+++ Src/utils.c	7 May 2005 16:11:26 -0000
@@ -358,14 +358,19 @@
 	    *p = '\0';
 	    continue;
 	}
-	sprintf(xbuf2, "%s/%s", xbuf, *pp);
-	t0 = readlink(unmeta(xbuf2), xbuf3, PATH_MAX);
+	if (ztrlen(xbuf) >= PATH_MAX-1 || ztrlen(*pp) >= PATH_MAX-1) {
+	  t0 = -1;
+	} else {
+	  sprintf(xbuf2, "%s/%s", xbuf, *pp);
+	  t0 = readlink(unmeta(xbuf2), xbuf3, PATH_MAX);
+	}
 	if (t0 == -1) {
 	    strcat(xbuf, "/");
 	    strcat(xbuf, *pp);
 	    zsfree(*pp);
 	} else {
-	    ret = 1;
+	    DPUTS(t0 == PATH_MAX, "BUG: overflow in readlink()");
+ 	    ret = 1;
 	    metafy(xbuf3, t0, META_NOALLOC);
 	    if (*xbuf3 == '/') {
 		strcpy(xbuf, "");


  reply	other threads:[~2005-05-07 16:23 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-05-01 11:44 David Remahl
2005-05-03 10:26 ` Peter Stephenson
2005-05-06  4:10   ` Geoff Wing
2005-05-07 16:23     ` Bart Schaefer [this message]
2005-05-08  0:41       ` Geoff Wing
2005-05-21 18:42         ` Bart Schaefer

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=1050507162306.ZM1184@candle.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=mason@primenet.com.au \
    --cc=zsh-workers@sunsite.dk \
    /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).