From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3222 invoked from network); 26 Oct 2001 18:27:34 -0000 Received: from ns2.primenet.com.au (HELO primenet.com.au) (?0nQ8DZf3PD7eQo13m2kq+29RKjjhq1o5?@203.24.36.3) by ns1.primenet.com.au with SMTP; 26 Oct 2001 18:27:34 -0000 Received: (qmail 6190 invoked from network); 26 Oct 2001 18:27:32 -0000 Received: from sunsite.dk (130.225.247.90) by proxy.melb.primenet.com.au with SMTP; 26 Oct 2001 18:27:32 -0000 Received: (qmail 25547 invoked by alias); 26 Oct 2001 18:27:22 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 16182 Received: (qmail 25533 invoked from network); 26 Oct 2001 18:27:21 -0000 Date: Fri, 26 Oct 2001 11:26:15 -0700 (PDT) From: Wayne Davison X-Sender: wayne@life.blorf.net To: Bart Schaefer Cc: Stepan Koltsov , zsh-workers@sunsite.dk Subject: Re: .zsh_history bugreport In-Reply-To: <1011026145410.ZM10567@candle.brasslantern.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Fri, 26 Oct 2001, Bart Schaefer wrote: > This was fixed by the patch in users/4269 and should be working in the > zsh-4.0.4 release from earlier today. Hmm. The start >= l (ell) check can only error-out if the null byte is at the start of the line (since once a section gets measured, it can't ever get any shorter). I think the real fix is to check if the string is too short when we didn't find a newline at the end (i.e. the buffer should be maxed out when fgets really didn't read a newline). What's currently happening is that we're doubling the readline buffer every time we get a short read, and we may have only really added a few bytes to the buffer. I think this is the right fix: Index: Src/hist.c --- Src/hist.c 2001/10/15 18:42:52 1.35 +++ Src/hist.c 2001/10/26 18:09:54 @@ -1772,11 +1772,10 @@ if (fgets(buf + start, *bufsiz - start, in)) { int l = strlen(buf); - if (start >= l) - return -1; - if (l) { if (buf[l - 1] != '\n' && !feof(in)) { + if (l < *bufsiz - 1) + return -1; *bufp = zrealloc(buf, 2 * (*bufsiz)); *bufsiz = 2 * (*bufsiz); return readhistline(l, bufp, bufsiz, in); ..wayne..