[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 22:48:15 +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.
>
> I noticed that the utilities are inconsistent about using BUFSIZ, and
> that the use of 'unsigned int' and 'int' for sizes is a bit confusing,
> so this patch fixes those neighboring problems too.
>
> 2003-09-04 Paul Eggert <address@hidden>
>
> Fix a bug reported by Andreas Schwab in
> <http://mail.gnu.org/archive/html/bug-coreutils/2003-09/msg00009.html>.
> * src/head.c (elide_tail_lines_pipe): Don't assign 0 or
> SAFE_READ_ERROR to tmp->nbytes.
> * src/tail.c (pipe_lines, pipe_bytes): Likewise.
>
> * src/head.c (struct linebuffer): Change nbytes and nlines
> from unsigned int to size_t. unsigned int is safe (after the
> changes noted above) but size_t is cleaner.
> * src/tail.c (struct linebuffer, struct charbuffer): Likewise.
> (pipe_bytes): Likewise for local variable 'i', which was 'int'.
>
> Standardize on BUFSIZ as opposed to other macro names and values.
> * src/head.c (BUFSIZE): Remove. All uses changed to BUFSIZ.
> * src/tail.c (BUFSIZ) [!defined BUFSIZ]: Remove.
> stdio.h has always defined it,
> and other code already assumes it's defined.
> * src/tr.c (BUFSIZ) [!defined BUFSIZ]: Likewise.
> (IO_BUF_SIZE): Remove; replace all uses with sizeof io_buf.
> (io_buf): IO_BUF_SIZE -> BUFSIZ.
Thanks again.
I've merged that in.