From: Peter Stephenson <pws@ibmth.df.unipi.it>
To: zsh-workers@sunsite.auc.dk
Subject: PATCH: 3.1.6-test-3: crash in _cvs dot-files stuff
Date: Wed, 28 Jul 1999 18:05:10 +0200 [thread overview]
Message-ID: <9907281605.AA27434@ibmth.df.unipi.it> (raw)
In-Reply-To: "Tanaka Akira"'s message of "29 Jul 1999 00:49:56 DFT." <rsq3dy8dba3.fsf@crane.jaist.ac.jp>
Tanaka Akira wrote:
> In article <9907281334.AA33903@ibmth.df.unipi.it>,
> Peter Stephenson <pws@ibmth.df.unipi.it> writes:
>
> > I can't get this any simple way, nor does the pattern itself seem to be the
> > problem. Is there an easy way of showing it (e.g. with a fixed argument to
> > compgen?)
>
> It is reproduced under my Solaris 7 environment.
>
> #0 0xff0b051c in makecomplistflags (cc=0x1278b0, s=0xce410 "", incmd=0,
> compadd=0) at zle_tricky.c:6380
> 6380 pa[o] = '\0';
This gives the game away. The pattern was arbitrarily limited to PATH_MAX
--- but unlike the resulting file, there's no reason why it should be, nor
was it tested. The following makes the buffer dynamically reallocated. At
this time pre-release it's good to be sensitive to memory leaks, but I
don't see one. Please don't take my word for it.
--- Src/Zle/zle_tricky.c.pm Tue Jul 27 17:07:08 1999
+++ Src/Zle/zle_tricky.c Wed Jul 28 17:49:06 1999
@@ -6283,8 +6283,8 @@
gen_matches_files(1, 0, 0);
/* The compctl has a glob pattern (compctl -g). */
if (cc->glob) {
- int ns, pl = strlen(prpre), o;
- char *g = dupstring(cc->glob), pa[PATH_MAX];
+ int ns, pl = strlen(prpre), o, paalloc;
+ char *g = dupstring(cc->glob), *pa;
char *p2, *p3;
int ne = noerrs, md = opts[MARKDIRS];
@@ -6298,8 +6298,9 @@
}
noerrs = 1;
addwhat = -6;
+ o = strlen(prpre);
+ pa = (char *)zalloc(paalloc = o + PATH_MAX);
strcpy(pa, prpre);
- o = strlen(pa);
opts[MARKDIRS] = 0;
/* The compctl -g string may contain more than *
@@ -6338,6 +6339,10 @@
else {
/* It's a simple pattern, so append it to *
* the path we have on the command line. */
+ int minlen = o + strlen(g);
+ if (minlen > paalloc)
+ pa = (char *)
+ zrealloc(pa, paalloc = minlen+1);
strcpy(pa + o, g);
addlinknode(l, dupstring(pa));
}
@@ -6383,6 +6388,8 @@
glob_pre = glob_suf = NULL;
noerrs = ne;
opts[MARKDIRS] = md;
+
+ zfree(pa, paalloc);
}
}
dirs++;
--
Peter Stephenson <pws@ibmth.df.unipi.it> Tel: +39 050 844536
WWW: http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy
next prev parent reply other threads:[~1999-07-28 16:36 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-07-28 5:12 PATCH: _cvs should complete dot-files (?) Bart Schaefer
1999-07-28 13:34 ` Peter Stephenson
1999-07-28 15:49 ` Tanaka Akira
1999-07-28 16:05 ` Peter Stephenson [this message]
1999-07-28 16:13 ` PATCH: 3.1.6-test-3: crash in _cvs dot-files stuff Peter Stephenson
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=9907281605.AA27434@ibmth.df.unipi.it \
--to=pws@ibmth.df.unipi.it \
--cc=zsh-workers@sunsite.auc.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).