zsh-workers
 help / color / mirror / code / Atom feed
From: Wayne Davison <wayned@users.sourceforge.net>
To: Bart Schaefer <schaefer@brasslantern.com>
Cc: Stepan Koltsov <yozh@mx1.ru>, zsh-workers@sunsite.dk
Subject: Re: .zsh_history bugreport
Date: Fri, 26 Oct 2001 11:26:15 -0700 (PDT)	[thread overview]
Message-ID: <Pine.LNX.4.21.0110261110100.7802-100000@life.blorf.net> (raw)
In-Reply-To: <1011026145410.ZM10567@candle.brasslantern.com>

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..


  parent reply	other threads:[~2001-10-26 18:27 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-10-26 14:26 Stepan Koltsov
2001-10-26 14:54 ` Bart Schaefer
2001-10-26 16:31   ` Stepan Koltsov
2001-10-26 18:26   ` Wayne Davison [this message]
2001-10-26 22:51     ` Bart Schaefer
2001-10-26 23:29       ` Wayne Davison
2001-10-30 17:36         ` Bart Schaefer
2001-10-30 18:25           ` Wayne Davison
2001-10-31 16:38             ` Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.21.0110261110100.7802-100000@life.blorf.net \
    --to=wayned@users.sourceforge.net \
    --cc=schaefer@brasslantern.com \
    --cc=yozh@mx1.ru \
    --cc=zsh-workers@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).