From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from euclid.skiles.gatech.edu (root@euclid.skiles.gatech.edu [130.207.146.50]) by melb.werple.net.au (8.7.5/8.7.3/2) with ESMTP id JAA25985 for ; Fri, 28 Jun 1996 09:19:31 +1000 (EST) Received: (from list@localhost) by euclid.skiles.gatech.edu (8.7.3/8.7.3) id SAA01562; Thu, 27 Jun 1996 18:33:20 -0400 (EDT) Resent-Date: Thu, 27 Jun 1996 18:33:20 -0400 (EDT) From: Zoltan Hidvegi Message-Id: <199606272142.XAA00788@hzoli.ppp.cs.elte.hu> Subject: Re: "read" broken in 2.6-beta21? To: cbuckley@cs.tcd.ie (Colm Buckley) Date: Thu, 27 Jun 1996 23:42:50 +0200 (MET DST) Cc: zsh-workers@math.gatech.edu (Zsh hacking and development) In-Reply-To: <199606270011.BAA07863@picasso.cs.tcd.ie> from Colm Buckley at "Jun 27, 96 01:11:06 am" X-Mailer: ELM [version 2.4ME+ PL17 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Resent-Message-ID: <"gvnjB3.0.HO.lmmqn"@euclid> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/1458 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu > > This has been affecting me recently; I just tracked it down to the > following: > > The "read" command in zsh2.6-beta21 behaves strangely when the input > exceeds 63 characters; the remaining characters in the line are > truncated. For example : > > $ read x > 1234567890123456789012345678901234567890123456789012345678901234567890 > $ echo $x > 123456789012345678901234567890123456789012345678901234567890123 > $ > > I don't *think* this affected previous versions of zsh. If a static > buffer is being used for "read", might I suggest that it be increased in > size to something greater than 64 bytes? Yes, this bug appeared in beta21 but not because of static buffers. The patch below should fix that. Zoltan *** Src/builtin.c 1996/06/26 22:32:07 2.47 --- Src/builtin.c 1996/06/27 21:25:38 *************** *** 4976,4983 **** *bptr++ = c; /* increase the buffer size, if necessary */ if (bptr >= buf + bsiz - 1) { buf = realloc(buf, bsiz *= 2); ! bptr = buf + (bsiz / 2); } } /* handle EOF */ --- 4976,4985 ---- *bptr++ = c; /* increase the buffer size, if necessary */ if (bptr >= buf + bsiz - 1) { + int blen = bptr - buf; + buf = realloc(buf, bsiz *= 2); ! bptr = buf + blen; } } /* handle EOF */ *************** *** 5055,5062 **** *bptr++ = c; /* increase the buffer size, if necessary */ if (bptr >= buf + bsiz - 1) { buf = realloc(buf, bsiz *= 2); ! bptr = buf + (bsiz / 2); } } while (bptr > buf && iwsep(bptr[-1])) --- 5057,5066 ---- *bptr++ = c; /* increase the buffer size, if necessary */ if (bptr >= buf + bsiz - 1) { + int blen = bptr - buf; + buf = realloc(buf, bsiz *= 2); ! bptr = buf + blen; } } while (bptr > buf && iwsep(bptr[-1]))