GNU bug report logs - #19154
[PATCH] Extend file size support in paste.

Previous Next

Package: coreutils;

Reported by: Tobias Stoeckmann <tobias <at> stoeckmann.org>

Date: Sun, 23 Nov 2014 18:51:02 UTC

Severity: normal

Tags: fixed, patch

Done: Assaf Gordon <assafgordon <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Pádraig Brady <P <at> draigBrady.com>
To: Tobias Stoeckmann <tobias <at> stoeckmann.org>, 19154 <at> debbugs.gnu.org
Subject: bug#19154: [PATCH] Extend file size support in paste.
Date: Sun, 23 Nov 2014 20:12:38 +0000
On 23/11/14 18:50, Tobias Stoeckmann wrote:
> The function paste_parallel just has to remember if there was a character
> in a line at all, not how many.  Changing size_t to a simple boolean
> statement removes a possible overflow situation with 4 GB files on 32 bit
> systems.
> ---
>  src/paste.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/src/paste.c b/src/paste.c
> index 2ca75d0..630a9a6 100644
> --- a/src/paste.c
> +++ b/src/paste.c
> @@ -235,7 +235,7 @@ paste_parallel (size_t nfiles, char **fnamptr)
>          {
>            int chr IF_LINT ( = 0);	/* Input character. */
>            int err IF_LINT ( = 0);	/* Input errno value.  */
> -          size_t line_length = 0;	/* Number of chars in line. */
> +          bool foundchar = false;	/* Found chars in a line. */
>  
>            if (fileptr[i])
>              {
> @@ -250,7 +250,7 @@ paste_parallel (size_t nfiles, char **fnamptr)
>  
>                while (chr != EOF)
>                  {
> -                  line_length++;
> +                  foundchar = true;
>                    if (chr == '\n')
>                      break;
>                    xputchar (chr);
> @@ -259,7 +259,7 @@ paste_parallel (size_t nfiles, char **fnamptr)
>                  }
>              }
>  
> -          if (line_length == 0)
> +          if (!foundchar)
>              {
>                /* EOF, read error, or closed file.
>                   If an EOF or error, close the file.  */
> 

Nice one. This would result in truncation of the output
iff there was a \n at position 2^32 in the file on a 32 bit system.
I'll apply that in a little while (I can't think of an efficient way to test).

Did you notice this through inspection or compiler warnings wrt integer overflow ?

thanks!
Pádraig.




This bug report was last modified 6 years and 231 days ago.

Previous Next


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