bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Coreutils 5.0.91: Fix crash in head/tail


From: Andreas Schwab
Subject: Coreutils 5.0.91: Fix crash in head/tail
Date: Wed, 03 Sep 2003 18:21:27 +0200
User-agent: Gnus/5.1002 (Gnus v5.10.2) Emacs/21.3.50 (gnu/linux)

tail crashes on read failures, like trying to read from a directory.
head has the same bug, but it is harder to trigger.

Andreas.

2003-09-03  Andreas Schwab  <address@hidden>

        * src/tail.c (pipe_lines): Don't truncate return value from
        safe_read.
        * src/head.c (elide_tail_lines_pipe): Likewise.

--- src/head.c.~1.86.~  2003-08-12 20:19:41.000000000 +0200
+++ src/head.c  2003-09-03 18:11:10.000000000 +0200
@@ -496,7 +496,8 @@ 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);
+      tmp->nbytes = n_read;
       if (n_read == 0 || n_read == SAFE_READ_ERROR)
        break;
       tmp->nlines = 0;
--- src/tail.c.~1.209.~ 2003-09-03 17:45:01.000000000 +0200
+++ src/tail.c  2003-09-03 18:10:14.000000000 +0200
@@ -536,7 +536,8 @@ pipe_lines (const char *pretty_filename,
   /* Input is always read into a fresh buffer.  */
   while (1)
     {
-      n_read = tmp->nbytes = safe_read (fd, tmp->buffer, BUFSIZ);
+      n_read = safe_read (fd, tmp->buffer, BUFSIZ);
+      tmp->nbytes = n_read;
       if (n_read == 0 || n_read == SAFE_READ_ERROR)
        break;
       *read_pos += n_read;

-- 
Andreas Schwab, SuSE Labs, address@hidden
SuSE Linux AG, Deutschherrnstr. 15-19, D-90429 Nürnberg
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."




reply via email to

[Prev in Thread] Current Thread [Next in Thread]