From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25726 invoked from network); 6 Jan 2006 11:13:53 -0000 X-Spam-Checker-Version: SpamAssassin 3.1.0 (2005-09-13) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00, FORGED_RCVD_HELO autolearn=ham version=3.1.0 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 6 Jan 2006 11:13:53 -0000 Received: (qmail 20649 invoked from network); 6 Jan 2006 11:13:47 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 6 Jan 2006 11:13:47 -0000 Received: (qmail 22716 invoked by alias); 6 Jan 2006 11:13:44 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 22122 Received: (qmail 22707 invoked from network); 6 Jan 2006 11:13:44 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 6 Jan 2006 11:13:44 -0000 Received: (qmail 20467 invoked from network); 6 Jan 2006 11:13:44 -0000 Received: from cluster-c.mailcontrol.com (HELO rly11c.srv.mailcontrol.com) (168.143.177.190) by a.mx.sunsite.dk with SMTP; 6 Jan 2006 11:13:43 -0000 Received: from exchange03.csr.com (uuk202166.uk.customer.alter.net [62.189.241.194] (may be forged)) by rly11c.srv.mailcontrol.com (MailControl) with ESMTP id k06BCv6k001080 for ; Fri, 6 Jan 2006 11:13:32 GMT Received: from news01 ([10.103.143.38]) by exchange03.csr.com with Microsoft SMTPSVC(5.0.2195.6713); Fri, 6 Jan 2006 11:13:02 +0000 Date: Fri, 6 Jan 2006 11:13:00 +0000 From: Peter Stephenson To: zsh-workers@sunsite.dk Subject: Re: ZSH-Bug (?): glibc, "double-free or corruption" Message-Id: <20060106111300.54c177ae.pws@csr.com> In-Reply-To: <43B07F7F.7010206@gmx.net> References: <43B07F7F.7010206@gmx.net> Organization: Cambridge Silicon Radio X-Mailer: Sylpheed version 0.9.12 (GTK+ 1.2.10; i386-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 06 Jan 2006 11:13:02.0139 (UTC) FILETIME=[289B68B0:01C612B2] X-Scanned-By: MailControl A-05-40-01 (www.mailcontrol.com) on 10.67.0.121 Jonas Kramer wrote: > Hi, > > I think I found a bug here. I'm just writing a CGI page in ZSH script > and the server (lighttpd 1.4.7) kills my script and logs messages like > the followings to the error log file: > The relevant source in init.z is the following: > > typeset -A POST > if [ $CONTENT_LENGTH -gt 0 ]; then > read -n 0 -k $CONTENT_LENGTH BUF As you pointed out, the -n should be -u. I think the -n itself is simply ignored if -c wasn't present. The interpretation of the code as it stands is that all the arguments from 0 onward are treated as parameter names, i.e. 0 -k $CONTENT_LENGTH BUF. Assigning to 0 is allowed; this changes $0, the script or function name. If there are at least 2 fields, it will try to assign to -k. This should produce an error message. $CONTENT_LENGTH is the interesting one. It will try to assign the field to the $CONTENT_LENGTH'th positional parameter. If this is a large number, you can get a huge positional array; but given this is supposed to be a maximum byte size for the read builtin it doesn't actually look like that will be a problem. If you later do something with $* or $@ or loop using $# you might have problems. BUF will be unproblematic. So I'm not really sure where your error messages were coming from. > IFS="\r\n" > for LINE in ($(print $BUF)); do There's an idiom for this in zsh, it's so common: for LINE in ${(f)BUF}; do This just handles newlines, so you may end up needing to strip carriage returns: for LINE in ${${(f)BUF}%%$'\r'}; do You shouldn't need the outer parentheses in any case. > IFS="=" > X=($(print $LINE)) Again, you can split into words without using IFS or an extra process: X=(${(s.=.)LINE}) -- Peter Stephenson Software Engineer CSR PLC, Churchill House, Cambridge Business Park, Cowley Road Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070 Your mail client is unable to display the latest news from CSR. To access our news copy this link into a web browser: http://www.csr.com/email_sig.html