[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Coreutils 5.0.91: Fix crash in head/tail
From: |
Jim Meyering |
Subject: |
Re: Coreutils 5.0.91: Fix crash in head/tail |
Date: |
Fri, 05 Sep 2003 11:36:34 +0200 |
Paul Eggert <address@hidden> wrote:
> Andreas Schwab <address@hidden> writes:
>
>> tail crashes on read failures, like trying to read from a directory.
>> head has the same bug, but it is harder to trigger.
>
> Thanks for catching that. Here's a proposed improvement on your
> patch, which avoids an unnecessary assignment to tmp->nbytes.
Thanks for the clean-up, but isn't that assignment to tmp->nbytes
necessary. There are uses after the main while loop, and I seem to
recall wanting to make the same change but not being able to.
...
> @@ -496,9 +494,10 @@ elide_tail_lines_pipe (const char *filen
> n_elide newlines, or until EOF, whichever comes first. */
> while (1)
> {
> - n_read = tmp->nbytes = safe_read (fd, tmp->buffer, BUFSIZ);
> + n_read = safe_read (fd, tmp->buffer, BUFSIZ);
> if (n_read == 0 || n_read == SAFE_READ_ERROR)
> break;
> + tmp->nbytes = n_read;
> tmp->nlines = 0;
> tmp->next = NULL;
>