From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24090 invoked by alias); 4 Dec 2011 12:42:18 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 29941 Received: (qmail 5382 invoked from network); 4 Dec 2011 12:42:16 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham version=3.3.2 Received-SPF: pass (ns1.primenet.com.au: SPF record at raveland.org designates 195.200.166.230 as permitted sender) Date: Sun, 4 Dec 2011 13:42:03 +0100 From: ports@raveland.org To: Peter Stephenson Cc: Zsh Hackers' List Subject: Re: zsh 4.3.13 released Message-ID: <20111204124203.GA1397@coredump.raveland.priv> References: <15488.1322689558@pws-pc.ntlworld.com> <20111203191925.GB1294@coredump.raveland.priv> <20111203194442.29d2f2a7@pws-pc.ntlworld.com> <20111203221953.GA18173@coredump.raveland.priv> <20111203225610.2d32f20a@pws-pc.ntlworld.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20111203225610.2d32f20a@pws-pc.ntlworld.com> X-Operating-System: OpenBSD 5.0 amd64 User-Agent: Mutt/1.5.21 (2010-09-15) On Sat, Dec 03, 2011 at 10:56:10PM +0000, Peter Stephenson wrote: > On Sat, 3 Dec 2011 23:19:54 +0100 > ports@raveland.org wrote: > > % zmodload -i bogus/notamodule > > Segmentation fault (core dumped) > >.... > > #0 0x000000000048f5bc in metafy (buf=0x207a096d7 "File not found", len=14, heap=1) at utils.c:4006 > > 4006 *e = '\0'; > > (gdb) bt > > #0 0x000000000048f5bc in metafy (buf=0x207a096d7 "File not found", len=14, heap=1) at utils.c:4006 > > heap=1 is META_USEHEAP: "get memory from the heap. This leaves buf > unchanged." However, the function unconditionally attempts to add nullL > termination. A defence lawyer could probably claim that adding a null > when there was one already there wasn't actually modification. Not sure > how we've avoided seeing this before. > > It seems some parts of the code are relying on the fact that the NULL > gets added even if the string doesn't need metafying. Treating the > absence of NULL termination as a reason for modifying the buffer was the > neatest of the three fixes I came up with. > > Index: Src/utils.c > =================================================================== > RCS file: /cvsroot/zsh/zsh/Src/utils.c,v > retrieving revision 1.264 > diff -p -u -r1.264 utils.c > --- Src/utils.c 15 Nov 2011 15:08:57 -0000 1.264 > +++ Src/utils.c 3 Dec 2011 22:51:19 -0000 > @@ -3959,7 +3959,7 @@ metafy(char *buf, int len, int heap) > if (imeta(*e++)) > meta++; > > - if (meta || heap == META_DUP || heap == META_HEAPDUP) { > + if (meta || heap == META_DUP || heap == META_HEAPDUP || *e != '\0') { > switch (heap) { > case META_REALLOC: > buf = zrealloc(buf, len + meta + 1); > @@ -4002,8 +4002,8 @@ metafy(char *buf, int len, int heap) > meta--; > } > } > + *e = '\0'; > } > - *e = '\0'; > return buf; > } > Works fine:: % zmodload -i bogus/notamodule zsh: failed to load module `bogus/notamodule': File not found Now Zsh works fine on OpenBSD. Thanks ! 40 successful test scripts, 0 failures, 0 skipped Regards, -- Pierre-Emmanuel André GPG key: 0x7AE329DC