Commit Graph

14 Commits

Author SHA1 Message Date
Mark Wielaard 6a8690fc8d Prepare for 1.0.8 release. 2019-07-13 17:17:58 +02:00
Mark Wielaard b07b105d1b Accept as many selectors as the file format allows.
But ignore any larger than the theoretical maximum, BZ_MAX_SELECTORS.

The theoretical maximum number of selectors depends on the maximum
blocksize (900000 bytes) and the number of symbols (50) that can be
encoded with a different Huffman tree. BZ_MAX_SELECTORS is 18002.

But the bzip2 file format allows the number of selectors to be encoded
with 15 bits (because 18002 isn't a factor of 2 and doesn't fit in
14 bits). So the file format maximum is 32767 selectors.

Some bzip2 encoders might actually have written out more selectors
than the theoretical maximum because they rounded up the number of
selectors to some convenient factor of 8.

The extra 14766 selectors can never be validly used by the decompression
algorithm. So we can read them, but then discard them.

This is effectively what was done (by accident) before we added a
check for nSelectors to be at most BZ_MAX_SELECTORS to mitigate
CVE-2019-12900.

The extra selectors were written out after the array inside the
EState struct. But the struct has extra space allocated after the
selector arrays of 18060 bytes (which is larger than 14766).
All of which will be initialized later (so the overwrite of that
space with extra selector values would have been harmless).
2019-07-09 23:29:44 +02:00
Mark Wielaard f319b98aad Prepare for 1.0.7 release. 2019-06-27 20:10:07 +02:00
Federico Mena Quintero ff98685015 Change a magic number (6) for a constant (BZ_N_GROUPS).
decompress.c (BZ2_decompress): Check nGroups against BZ_N_GROUPS.
2019-06-24 15:41:58 +02:00
Albert Astals Cid 7ed62bfb46 Make sure nSelectors is not out of range
nSelectors is used in a loop from 0 to nSelectors to access selectorMtf
which is
	UChar    selectorMtf[BZ_MAX_SELECTORS];
so if nSelectors is bigger than BZ_MAX_SELECTORS it'll do an invalid memory
access

Fixes out of bounds access discovered while fuzzying karchive

This was reported as CVE-2019-12900
BZ2_decompress in decompress.c in bzip2 through 1.0.6 has an
out-of-bounds write when there are many selectors.
2019-06-24 15:34:05 +02:00
Mark Wielaard 5b923861db Change Julian's email address to jseward@acm.org 2019-03-30 22:56:16 +01:00
Julian Seward 962d60610c bzip2-1.0.6 2010-09-06 22:13:13 +02:00
Julian Seward a1d78c5501 bzip2-1.0.5 2007-12-10 22:13:13 +01:00
Julian Seward f10a33538e bzip2-1.0.4 2006-12-20 22:13:13 +01:00
Julian Seward 4d540bfc95 bzip2-1.0.3 2005-02-15 22:13:13 +01:00
Julian Seward 099d844292 bzip2-1.0.2 2001-12-30 22:13:13 +01:00
Julian Seward 795b859eee bzip2-1.0.1 2000-06-24 22:13:13 +02:00
Julian Seward f93cd82a9a bzip2-0.9.5d 1999-09-04 22:13:13 +02:00
Julian Seward 977101ad5f bzip2-0.9.0c 1998-08-23 22:13:13 +02:00