GNU bug report logs - #46048
split -n K/N loses data, sum of output files is smaller than input file.

Previous Next

Package: coreutils;

Reported by: Paul Hirst <contact <at> phirst.org>

Date: Sat, 23 Jan 2021 08:26:02 UTC

Severity: normal

Done: Pádraig Brady <P <at> draigBrady.com>

Bug is archived. No further changes may be made.

Full log


Message #11 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Pádraig Brady <P <at> draigBrady.com>
To: bug-coreutils <at> gnu.org
Subject: Re: bug#46048: split -n K/N loses data, sum of output files is
 smaller than input file.
Date: Sun, 24 Jan 2021 16:58:43 +0000
On 24/01/2021 16:52, Pádraig Brady wrote:
> diff --git a/src/split.c b/src/split.c
> index 0660da13f..6aa8d50e9 100644
> --- a/src/split.c
> +++ b/src/split.c
> @@ -1001,7 +1001,7 @@ bytes_chunk_extract (uintmax_t k, uintmax_t n, char *buf, size_t bufsize,
>        }
>      else
>        {
> -      if (lseek (STDIN_FILENO, start, SEEK_CUR) < 0)
> +      if (lseek (STDIN_FILENO, start, SEEK_SET) < 0)
>            die (EXIT_FAILURE, errno, "%s", quotef (infile));
>          initial_read = SIZE_MAX;
>        }

The same adjustment is needed in lines_chunk_split()
I'll add a test also.

cheers,
Pádraig





This bug report was last modified 4 years and 97 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.