Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Lethal option-related bug



hzoli@xxxxxxxxxx wrote:
> > It turns out to be easy to reproduce:
> > 
> > ./zsh -s
> > zsh: 7863 segmentation fault (core dumped)  ./zsh -s
> > the right fix, so I'll leave it.
> 
> OK, below is a simple and clean fix.  POSIX says that if IFS is unset it
> should be treated as if it were set to space-tab-newline.  Zsh does this
> but it adds an extra null here.

No, that doesn't work: you need to fix up wordchars as well which
causes the same problem.  (I didn't mention that in the original post
because I assumed whoever was making the patch would try it out and
discover this and perhaps other problems.)  The following less elegant
patch does at least fix the core dump.

*** Src/init.c.ifs	Mon Jul 29 18:01:46 1996
--- Src/init.c	Tue Jul 30 10:14:40 1996
***************
*** 59,64 ****
--- 59,67 ----
      opts[MONITOR] = 1;   /* may be unset in init_io() */
      opts[PRIVILEGED] = (getuid() != geteuid() || getgid() != getegid());
      opts[USEZLE] = 1;   /* may be unset in init_io() */
+     ifs         = ztrdup(" \t\n  ");
+     ifs[3]      = Meta;
+     wordchars   = ztrdup(DEFAULT_WORDCHARS);
      parseargs(argv);   /* sets INTERACTIVE, SHINSTDIN and SINGLECOMMAND */
  
      SHTTY = -1;
***************
*** 519,527 ****
  
      if (!(ttystrname = ztrdup(ttyname(SHTTY))))
  	ttystrname = ztrdup("");
-     ifs         = ztrdup(" \t\n  ");
-     ifs[3]      = Meta;
-     wordchars   = ztrdup(DEFAULT_WORDCHARS);
      postedit    = ztrdup("");
      underscore  = ztrdup("");
  
--- 522,527 ----

-- 
Peter Stephenson <pws@xxxxxx>       Tel: +49 33762 77366
WWW:  http://www.ifh.de/~pws/       Fax: +49 33762 77330
Deutches Electronen-Synchrotron --- Institut fuer Hochenergiephysik Zeuthen
DESY-IfH, 15735 Zeuthen, Germany.



Messages sorted by: Reverse Date, Date, Thread, Author