summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRoss Lagerwall <ross.lagerwall@citrix.com>2024-07-17 17:20:16 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2024-08-03 08:49:38 +0200
commit78648d68a51f0ac78c5505490467da9c45c27afc (patch)
tree3d8e5b7cff98a5a46191e8e22323399e4612e20d /lib
parentadb7146d1758daa0592a846922368a68cb5dc9cf (diff)
downloadlinux-78648d68a51f0ac78c5505490467da9c45c27afc.tar.gz
linux-78648d68a51f0ac78c5505490467da9c45c27afc.tar.bz2
linux-78648d68a51f0ac78c5505490467da9c45c27afc.zip
decompress_bunzip2: fix rare decompression failure
commit bf6acd5d16057d7accbbb1bf7dc6d8c56eeb4ecc upstream. 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/20240717162016.1514077-1-ross.lagerwall@citrix.com Fixes: bc22c17e12c1 ("bzip2/lzma: library support for gzip, bzip2 and lzma decompression") Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com> Cc: Alain Knaff <alain@knaff.lu> Cc: "H. Peter Anvin" <hpa@zytor.com> Cc: <stable@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/decompress_bunzip2.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/decompress_bunzip2.c b/lib/decompress_bunzip2.c
index 3518e7394eca..ca736166f100 100644
--- a/lib/decompress_bunzip2.c
+++ b/lib/decompress_bunzip2.c
@@ -232,7 +232,8 @@ static int INIT get_next_block(struct bunzip_data *bd)
RUNB) */
symCount = symTotal+2;
for (j = 0; j < groupCount; j++) {
- unsigned char length[MAX_SYMBOLS], temp[MAX_HUFCODE_BITS+1];
+ unsigned char length[MAX_SYMBOLS];
+ unsigned short temp[MAX_HUFCODE_BITS+1];
int minLen, maxLen, pp;
/* Read Huffman code lengths for each symbol. They're
stored in a way similar to mtf; record a starting