bug#79508: [PATCH] tail: fix seeking backward
Pádraig Brady <[email protected]>
| Newsgroups | gmane.comp.gnu.core-utils.bugs |
|---|---|
| Message-ID | <[email protected]> |
On 24/09/2025 17:05, Hannes Braun via GNU coreutils Bug Reports wrote:
> * src/tail.c (file_lines): Seek to the previous block instead of the
> beginning (or a little before) of the block that was just scanned.
> Otherwise, the same block is read and scanned (at least partially)
> again. This bug was introduced by commit v9.7-219-g976f8abc1.
> ---
> src/tail.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/tail.c b/src/tail.c
> index b8bef1d91..c7779c77d 100644
> --- a/src/tail.c
> +++ b/src/tail.c
> @@ -596,7 +596,7 @@ file_lines (char const *prettyname, int fd, struct stat const *sb,
> goto free_buffer;
> }
>
> - pos = xlseek (fd, -bufsize, SEEK_CUR, prettyname);
> + pos = xlseek (fd, -(bufsize + bytes_read), SEEK_CUR, prettyname);
> bytes_read = read (fd, buffer, bufsize);
> if (bytes_read < 0)
> {
Handled on the main list, with:
https://github.com/coreutils/coreutils/commit/914972e
Marking this as done.
thanks,
Padraig