From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10280 invoked from network); 3 Jun 2007 17:36:38 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.0 (2007-05-01) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00 autolearn=no version=3.2.0 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 3 Jun 2007 17:36:38 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 47324 invoked from network); 3 Jun 2007 17:36:31 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 3 Jun 2007 17:36:31 -0000 Received: (qmail 25070 invoked by alias); 3 Jun 2007 17:36:28 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 23511 Received: (qmail 25059 invoked from network); 3 Jun 2007 17:36:27 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 3 Jun 2007 17:36:27 -0000 Received: (qmail 46931 invoked from network); 3 Jun 2007 17:36:27 -0000 Received: from mtaout02-winn.ispmail.ntl.com (81.103.221.48) by a.mx.sunsite.dk with SMTP; 3 Jun 2007 17:36:23 -0000 Received: from aamtaout02-winn.ispmail.ntl.com ([81.103.221.35]) by mtaout02-winn.ispmail.ntl.com with ESMTP id <20070603173622.WLUI4.mtaout02-winn.ispmail.ntl.com@aamtaout02-winn.ispmail.ntl.com> for ; Sun, 3 Jun 2007 18:36:22 +0100 Received: from pws-pc.ntlworld.com ([81.107.45.67]) by aamtaout02-winn.ispmail.ntl.com with ESMTP id <20070603173622.BKBO17393.aamtaout02-winn.ispmail.ntl.com@pws-pc.ntlworld.com> for ; Sun, 3 Jun 2007 18:36:22 +0100 Received: from pws-pc.ntlworld.com (pws-pc.ntlworld.com [127.0.0.1]) by pws-pc.ntlworld.com (8.13.8/8.13.8) with ESMTP id l53HaAJI003047 for ; Sun, 3 Jun 2007 18:36:11 +0100 Message-Id: <200706031736.l53HaAJI003047@pws-pc.ntlworld.com> From: Peter Stephenson To: zsh-workers@sunsite.dk Subject: Re: [Bug] ZSH segmentation fault In-Reply-To: Message from DervishD of "Sun, 03 Jun 2007 18:43:56 +0200." <20070603164356.GA21731@DervishD> Date: Sun, 03 Jun 2007 18:36:10 +0100 DervishD wrote: > While I understand that running such scripts is very unusual, I > think that just segfaulting is not a correct way of dealing with errors. I didn't claim it was, indeed I think I implied the opposite. I can easily work around this one, though even this isn't completely trivial. Index: Src/exec.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/exec.c,v retrieving revision 1.115 diff -u -r1.115 exec.c --- Src/exec.c 29 May 2007 14:16:03 -0000 1.115 +++ Src/exec.c 3 Jun 2007 17:32:50 -0000 @@ -3111,7 +3111,13 @@ ; for (;;) { if (bptr == buf + bsiz) { - buf = realloc(buf, 2 * bsiz); + char *newbuf = realloc(buf, 2 * bsiz); + if (!newbuf) { + /* out of memory */ + zfree(buf, bsiz); + return NULL; + } + buf = newbuf; t = buf + bsiz - (bptr - t); bptr = buf + bsiz; bsiz *= 2; Index: Src/lex.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/lex.c,v retrieving revision 1.38 diff -u -r1.38 lex.c --- Src/lex.c 23 Jan 2007 16:07:47 -0000 1.38 +++ Src/lex.c 3 Jun 2007 17:32:51 -0000 @@ -356,6 +356,16 @@ ALLOWHIST cmdpop(); hwend(); + if (!name) { + zerr("here document too large"); + while (hdocs) { + next = hdocs->next; + zfree(hdocs, sizeof(struct heredocs)); + hdocs = next; + } + tok = LEXERR; + break; + } setheredoc(hdocs->pc, REDIR_HERESTR, name); zfree(hdocs, sizeof(struct heredocs)); hdocs = next; -- Peter Stephenson Web page now at http://homepage.ntlworld.com/p.w.stephenson/