]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tail: fix an inconsequential bug spotted by coverity
authorJim Meyering <meyering@redhat.com>
Wed, 1 Jun 2011 11:48:12 +0000 (13:48 +0200)
committerJim Meyering <meyering@redhat.com>
Wed, 1 Jun 2011 11:49:04 +0000 (13:49 +0200)
* src/tail.c (start_bytes): Increase *READ_POS (not READ_POS)
by the number of bytes read.  This is a real bug that happens
to have no consequence in practice.  First, this code is exercised
only when tailing-forever a non-regular file by bytes, and with a
start-relative offset, e.g., "mkfifo f; tail -f -c +3 f", but even
then, the invalid READ_POS value does not influence how tail works.
It is stored in the File_spec.size member, but that member is not
used at all in tail_forever_inotify, and in tail_forever, it is
used only when the File_spec refers to a regular file.

src/tail.c

index 714e278e457f10b94f76ec1ed541d0610d1b8c9f..f315776331e0c45e543135b417fd852b55052601 100644 (file)
@@ -818,7 +818,7 @@ start_bytes (const char *pretty_filename, int fd, uintmax_t n_bytes,
           error (0, errno, _("error reading %s"), quote (pretty_filename));
           return 1;
         }
-      read_pos += bytes_read;
+      *read_pos += bytes_read;
       if (bytes_read <= n_bytes)
         n_bytes -= bytes_read;
       else