bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re : Bash scripting and large files: input with the read builtin from a


From: Jean-François Gagné
Subject: Re : Bash scripting and large files: input with the read builtin from a redirection gives unexpected result with files larger than 2GB.
Date: Thu, 8 Mar 2012 05:11:46 -0800 (PST)

Hi Andreas,

The patch worked when applied on bash 4.1.0 :
address@hidden:/home/jgagne/tmp$ echo address@hidden
>4 1 0 1 release x86_64-unknown-linux-gnu
 
It also works on bash 4.2.0:
address@hidden:/home/jgagne/tmp$ echo address@hidden
>4 2 0 1 release x86_64-unknown-linux-gnu

I also tested the patch on bash 4.1.11 and 4.2.20, and the bug is reproduced 
before applying the batch, and is gone after:
address@hidden:/home/jgagne/tmp/bash-4.1$ echo address@hidden
>4 1 11 5 release x86_64-unknown-linux-gnu
>
>
>address@hidden:/home/jgagne/tmp$ echo address@hidden
>4 2 20 2 release x86_64-unknown-linux-gnu

So no doubts left, your patch is the solution to this bug.

Thanks and regards,

Jean-François Gagné


________________________________
 De : Andreas Schwab <address@hidden>
À : Chet Ramey <address@hidden> 
Cc : Jean-François Gagné <address@hidden>; "address@hidden" <address@hidden>; 
"address@hidden" <address@hidden> 
Envoyé le : Dimanche 4 mars 2012 22h51
Objet : Re: Bash scripting and large files: input with the read builtin from a 
redirection gives unexpected result with files larger than 2GB.
 
Bob Proulx <address@hidden> writes:

> Chet Ramey wrote:
>> Jean-François Gagné wrote:
>> > uname output: Linux xxxxxxxx 2.6.32-5-amd64 #1 SMP Tue Jun 14 09:42:28 UTC 
>> > 2011 x86_64 GNU/Linux
>> > Machine Type: x86_64-pc-linux-gnu
>>
>> Compile and run the attached program.  If it prints out `4', which it does
>> on all of the Debian systems I've tried, file offsets are limited to 32
>> bits, and accessing files greater than 2 GB is going to be unreliable.
>
> Apparently all of the Debian systems you have tried are 32-bits
> systems.  On the reporter's 64-bit amd64 system it will print out 8.

But it won't help if you don't use it.

diff --git a/lib/sh/zread.c b/lib/sh/zread.c
index 0fd1199..3731a41 100644
--- a/lib/sh/zread.c
+++ b/lib/sh/zread.c
@@ -161,7 +161,7 @@ zsyncfd (fd)
      int fd;
{
   off_t off;
-  int r;
+  off_t r;

   off = lused - lind;
   r = 0;

Andreas.

-- 
Andreas Schwab, address@hidden
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."


reply via email to

[Prev in Thread] Current Thread [Next in Thread]