zsh-workers
 help / color / mirror / code / Atom feed
From: Geoff Wing <mason@primenet.com.au>
To: zsh-workers@sunsite.dk
Subject: Re: Obscure overflow with very long path; completion
Date: Fri, 6 May 2005 04:10:00 +0000 (UTC)	[thread overview]
Message-ID: <slrnd7lrgo.32l.mason@g.primenet.com.au> (raw)
In-Reply-To: <200505031026.j43AQwBE014903@news01.csr.com>

Peter Stephenson <pws@csr.com> typed:
: David Remahl wrote:
:> Summary:
:> Some very special circumstances triggers a buffer overflow of some  
:> kind (I believe it is on the heap, but I have not had time to look  
:> into it in detail) in the cd builtin.
: I couldn't get this to happen with Fedora Core 3 on x86.  It's possible
: it's some library bug, but I agree it's more likely there's some
: well-masked problem in memory management in zsh.

I get 98 of them built using the provided method before crashing.  Then

% zsh -f
% cd /tmp
% for I in {1..98}; cd aaaaaaaaaaaaaaaaaaaa
% pwd | wc
       1       1    2063
% setopt chaselinks
% cd /tmp
% for I in {1..98}; cd aaaaaaaaaaaaaaaaaaaa

(gdb) bt
#0  0xbdbcba91 in xsymlink (
    s=0x80e80c8 "/tmp/", 'a' <repeats 20 times>, "/", 'a' <repeats 20 times>, "/", 'a' <repeats 20 times>, "/", 'a' <repeats 20 times>, "/", 'a' <repeats 20 times>, "/", 'a' <repeats 20 times>, "/", 'a' <repeats 20 times>, "/", 'a' <repeats 20 times>, "/", 'a' <repeats 20 times>, "/aaaaaa"...) at utils.c:395
#1  0xbdbcb701 in findpwd (
    s=0x80e80c8 "/tmp/", 'a' <repeats 20 times>, "/", 'a' <repeats 20 times>, "/", 'a' <repeats 20 times>, "/", 'a' <repeats 20 times>, "/", 'a' <repeats 20 times>, "/", 'a' <repeats 20 times>, "/", 'a' <repeats 20 times>, "/", 'a' <repeats 20 times>, "/", 'a' <repeats 20 times>, "/aaaaaa"...) at utils.c:279
#2  0xbdb7482e in cd_new_pwd (func=10, dir=0x8091ca8) at builtin.c:1107

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.  I guess there should be some limiters to stop somewhere and obey
PATH_MAX (or some magic number we wish to support).

Regards,
Geoff


  reply	other threads:[~2005-05-06  4:10 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 [this message]
2005-05-07 16:23     ` Bart Schaefer
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=slrnd7lrgo.32l.mason@g.primenet.com.au \
    --to=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).