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.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 19154 in the body.
You can then email your comments to 19154 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-coreutils <at> gnu.org:
bug#19154; Package coreutils. (Sun, 23 Nov 2014 18:51:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Tobias Stoeckmann <tobias <at> stoeckmann.org>:
New bug report received and forwarded. Copy sent to bug-coreutils <at> gnu.org. (Sun, 23 Nov 2014 18:51:02 GMT) Full text and rfc822 format available.

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

From: Tobias Stoeckmann <tobias <at> stoeckmann.org>
To: bug-coreutils <at> gnu.org
Subject: [PATCH] Extend file size support in paste.
Date: Sun, 23 Nov 2014 19:50:05 +0100
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.  */
-- 
2.1.1





Information forwarded to bug-coreutils <at> gnu.org:
bug#19154; Package coreutils. (Sun, 23 Nov 2014 20:13:02 GMT) Full text and rfc822 format available.

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

From: Pádraig Brady <P <at> draigBrady.com>
To: Tobias Stoeckmann <tobias <at> stoeckmann.org>, 19154 <at> debbugs.gnu.org
Subject: Re: 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.




Information forwarded to bug-coreutils <at> gnu.org:
bug#19154; Package coreutils. (Sun, 23 Nov 2014 20:27:01 GMT) Full text and rfc822 format available.

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

From: Tobias Stöckmann <tobias <at> stoeckmann.org>
To: Pádraig Brady <p <at> draigbrady.com>, 
 19154 <19154 <at> debbugs.gnu.org>
Subject: Re: bug#19154: [PATCH] Extend file size support in paste.
Date: Sun, 23 Nov 2014 21:26:47 +0100 (CET)
Haven't used any tool except an editor. ;)

I was curious about paste's internals, so I gave my reviewing skills a try.


Tobias

> On November 23, 2014 at 9:12 PM Pádraig Brady <P <at> draigBrady.com> wrote:
> 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.




Information forwarded to bug-coreutils <at> gnu.org:
bug#19154; Package coreutils. (Wed, 10 Oct 2018 15:56:01 GMT) Full text and rfc822 format available.

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

From: Assaf Gordon <assafgordon <at> gmail.com>
To: 19154 <at> debbugs.gnu.org
Date: Wed, 10 Oct 2018 09:55:10 -0600
tags 19154 fixed
close 19154
stop


Pushed in 
https://git.savannah.gnu.org/cgit/coreutils.git/commit/?id=16e2347bd545057b04a97115563e606ad822ec33

closing.





Added tag(s) fixed. Request was from Assaf Gordon <assafgordon <at> gmail.com> to control <at> debbugs.gnu.org. (Wed, 10 Oct 2018 15:56:02 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 19154 <at> debbugs.gnu.org and Tobias Stoeckmann <tobias <at> stoeckmann.org> Request was from Assaf Gordon <assafgordon <at> gmail.com> to control <at> debbugs.gnu.org. (Wed, 10 Oct 2018 15:56:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 08 Nov 2018 12:24:06 GMT) Full text and rfc822 format available.

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

Previous Next


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