Skip to content

Commit bf6acd5

Browse files
rosslagerwallakpm00
authored andcommitted
decompress_bunzip2: fix rare decompression failure
The decompression code parses a huffman tree and counts the number of symbols for a given bit length. In rare cases, there may be >= 256 symbols with a given bit length, causing the unsigned char to overflow. This causes a decompression failure later when the code tries and fails to find the bit length for a given symbol. Since the maximum number of symbols is 258, use unsigned short instead. Link: https://lkml.kernel.org/r/[email protected] Fixes: bc22c17 ("bzip2/lzma: library support for gzip, bzip2 and lzma decompression") Signed-off-by: Ross Lagerwall <[email protected]> Cc: Alain Knaff <[email protected]> Cc: "H. Peter Anvin" <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent d659b71 commit bf6acd5

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/decompress_bunzip2.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,8 @@ static int INIT get_next_block(struct bunzip_data *bd)
232232
RUNB) */
233233
symCount = symTotal+2;
234234
for (j = 0; j < groupCount; j++) {
235-
unsigned char length[MAX_SYMBOLS], temp[MAX_HUFCODE_BITS+1];
235+
unsigned char length[MAX_SYMBOLS];
236+
unsigned short temp[MAX_HUFCODE_BITS+1];
236237
int minLen, maxLen, pp;
237238
/* Read Huffman code lengths for each symbol. They're
238239
stored in a way similar to mtf; record a starting

0 commit comments

Comments
 (0)