aboutsummaryrefslogtreecommitdiff
path: root/c/dec/decode.c
diff options
context:
space:
mode:
authorEugene Kliuchnikov <eustas.ru@gmail.com>2020-08-26 12:32:27 +0200
committerGitHub <noreply@github.com>2020-08-26 12:32:27 +0200
commit223d80cfbec8fd346e32906c732c8ede21f0cea6 (patch)
treede47f73fd7323e327cd9c9f20100da8ed4e13f54 /c/dec/decode.c
parent0c5603e07bed1d5fbb45e38f9bdf0e4560fde3f0 (diff)
downloadbrotli-223d80cfbec8fd346e32906c732c8ede21f0cea6.zip
brotli-223d80cfbec8fd346e32906c732c8ede21f0cea6.tar.gz
brotli-223d80cfbec8fd346e32906c732c8ede21f0cea6.tar.bz2
Update (#826)
* IMPORTANT: decoder: fix potential overflow when input chunk is >2GiB * simplify max Huffman table size calculation * eliminate symbol duplicates (static arrays in .h files) * minor combing in research/ code
Diffstat (limited to 'c/dec/decode.c')
-rw-r--r--c/dec/decode.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/c/dec/decode.c b/c/dec/decode.c
index 9cdbb57..ae5a3d3 100644
--- a/c/dec/decode.c
+++ b/c/dec/decode.c
@@ -875,8 +875,8 @@ static BROTLI_INLINE uint32_t ReadBlockLength(const HuffmanCode* table,
uint32_t code;
uint32_t nbits;
code = ReadSymbol(table, br);
- nbits = kBlockLengthPrefixCode[code].nbits; /* nbits == 2..24 */
- return kBlockLengthPrefixCode[code].offset + BrotliReadBits24(br, nbits);
+ nbits = _kBrotliPrefixCodeRanges[code].nbits; /* nbits == 2..24 */
+ return _kBrotliPrefixCodeRanges[code].offset + BrotliReadBits24(br, nbits);
}
/* WARNING: if state is not BROTLI_STATE_READ_BLOCK_LENGTH_NONE, then
@@ -894,13 +894,14 @@ static BROTLI_INLINE BROTLI_BOOL SafeReadBlockLength(
}
{
uint32_t bits;
- uint32_t nbits = kBlockLengthPrefixCode[index].nbits; /* nbits == 2..24 */
+ uint32_t nbits = _kBrotliPrefixCodeRanges[index].nbits;
+ uint32_t offset = _kBrotliPrefixCodeRanges[index].offset;
if (!BrotliSafeReadBits(br, nbits, &bits)) {
s->block_length_index = index;
s->substate_read_block_length = BROTLI_STATE_READ_BLOCK_LENGTH_SUFFIX;
return BROTLI_FALSE;
}
- *result = kBlockLengthPrefixCode[index].offset + bits;
+ *result = offset + bits;
s->substate_read_block_length = BROTLI_STATE_READ_BLOCK_LENGTH_NONE;
return BROTLI_TRUE;
}