bug-gzip
[Top][All Lists]
Advanced

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

Rare issue in ignoring padding


From: Daniel Barkalow
Subject: Rare issue in ignoring padding
Date: Fri, 9 Oct 2009 18:22:32 -0400 (EDT)
User-agent: Alpine 2.00 (LNX 1167 2008-08-23)

The code to ignore trailing zeros from:

        * gzip.c (get_method): Don't complain about trailing zeros at
        the end of a gzipped file, as they're commonly appended to fill
        out a block (e.g. by GNU tar).

has a rare bug: if there is exactly one trailing zero (because, for 
example, your compressed tar file was one byte short of a block), gzip 
gets only the first byte of the magic, and it's zero, but then it hits the 
end of the file on the second byte of the magic.

I think this should affect only that case, and make it not fail:

--- gzip.c~     2009-09-26 14:56:02.000000000 -0400
+++ gzip.c      2009-10-09 18:17:39.000000000 -0400
@@ -1266,8 +1266,13 @@
        /* If try_byte returned EOF, magic[1] == (char) EOF.  */
     } else {
        magic[0] = (char)get_byte();
-       magic[1] = (char)get_byte();
-       imagic1 = 0; /* avoid lint warning */
+       if (magic[0]) {
+           magic[1] = (char)get_byte();
+           imagic1 = 0; /* avoid lint warning */
+       } else {
+           imagic1 = try_byte ();
+           magic[1] = (char) imagic1;
+       }
     }
     method = -1;                 /* unknown yet */
     part_nb++;                   /* number of parts in gzip file */




reply via email to

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