From: Glenn L McGrath Date: Thu, 29 Nov 2001 06:36:56 +0000 (-0000) Subject: gunzip was incorrectly reporting a failed crc and length (discovered by X-Git-Tag: 0_60_3~202 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=38288bbf4cb26be1d1b3ee9175666d6819892a9e;p=oweals%2Fbusybox.git gunzip was incorrectly reporting a failed crc and length (discovered by Chang, Shu-Hao). The bitbuffer needs to be unwound after decompression, as it was eating into the crc/size field. --- diff --git a/archival/libunarchive/decompress_unzip.c b/archival/libunarchive/decompress_unzip.c index bb32891be..69cc8198b 100644 --- a/archival/libunarchive/decompress_unzip.c +++ b/archival/libunarchive/decompress_unzip.c @@ -875,6 +875,14 @@ static int inflate(void) } } while (!e); + /* Undo too much lookahead. The next read will be byte aligned so we + * can discard unused bits in the last meaningful byte. + */ + while (bk >= 8) { + bk -= 8; + ungetc((bb << bk), in_file); + } + /* flush out window */ flush_window(); diff --git a/archival/libunarchive/unzip.c b/archival/libunarchive/unzip.c index bb32891be..69cc8198b 100644 --- a/archival/libunarchive/unzip.c +++ b/archival/libunarchive/unzip.c @@ -875,6 +875,14 @@ static int inflate(void) } } while (!e); + /* Undo too much lookahead. The next read will be byte aligned so we + * can discard unused bits in the last meaningful byte. + */ + while (bk >= 8) { + bk -= 8; + ungetc((bb << bk), in_file); + } + /* flush out window */ flush_window(); diff --git a/libbb/unzip.c b/libbb/unzip.c index bb32891be..69cc8198b 100644 --- a/libbb/unzip.c +++ b/libbb/unzip.c @@ -875,6 +875,14 @@ static int inflate(void) } } while (!e); + /* Undo too much lookahead. The next read will be byte aligned so we + * can discard unused bits in the last meaningful byte. + */ + while (bk >= 8) { + bk -= 8; + ungetc((bb << bk), in_file); + } + /* flush out window */ flush_window();