[Top][All Lists]

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

Re: gzip --force bug

From: Mark Adler
Subject: Re: gzip --force bug
Date: Thu, 4 Feb 2010 09:24:31 -0800

On Feb 3, 2010, at 10:33 PM, Jim Meyering wrote:
> I may have encountered this already
> when I was trying to create a compressed file
> of size one smaller than gzip's internal buffer size.
> It appeared to be impossible.


It's certainly possible to do that.  For example:

$ dd ibs=1 count=32744 < /dev/random 2> /dev/null | gzip | tee 32km1.gz | wc -c

(It's unlikely but possible for you to get random data that is slightly 
compressible and end up with a different number.  If that happens, just try 

The reason that the "if (imagic1 != EOF)" before the "inptr--;" doesn't cure 
any realizable bug is sort of accidental.  If imagic1 is EOF, that means that a 
routine was called to try to load more data into the input buffer and failed, 
leaving insize set to zero.  Then there is no value of inptr that satisfies 
inptr < insize, since inptr is unsigned.  So it doesn't even matter what inptr 
is at that point.

I am leaving the "if (imagic1 != EOF)" there anyway, since without it it takes 
a fair bit of code inspection to determine that its absence is not a bug.


reply via email to

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