mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-18 08:32:11 +01:00
Check distance > 0 for decode_huffman_slow
decode_huffman_fast already does this. The slow flavor should too. Updates https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=6524
This commit is contained in:
1 parent
b059480f66
commit
bbc3d34e1b
3 files changed
+12
No files matched your search
@@ -2645,6 +2645,11 @@ static wuffs_deflate__status wuffs_deflate__decoder__decode_huffman_slow(
|
||||
v_bits >>= v_table_entry_n_bits;
|
||||
v_n_bits -= v_table_entry_n_bits;
|
||||
}
|
||||
if (v_distance <= 0) {
|
||||
status =
|
||||
WUFFS_DEFLATE__ERROR_INTERNAL_ERROR_INCONSISTENT_HUFFMAN_DECODER_STATE;
|
||||
goto exit;
|
||||
}
|
||||
v_n_copied = 0;
|
||||
while (true) {
|
||||
if (((uint64_t)(v_distance)) >
|
||||
|
||||
@@ -246,6 +246,8 @@ pri func decoder.decode_huffman_fast?(dst writer1, src reader1)() {
|
||||
}
|
||||
|
||||
// distance = base number + extra bits.
|
||||
//
|
||||
// TODO: the upper bound isn't right. 0x8000 is a valid distance.
|
||||
var distance u32[..0x7FFF] = (table_entry >> 8) & 0x7FFF
|
||||
table_entry_n_bits = (table_entry >> 4) & 0x0F
|
||||
if table_entry_n_bits > 0 {
|
||||
|
||||
@@ -158,6 +158,8 @@ pri func decoder.decode_huffman_slow?(dst writer1, src reader1)() {
|
||||
}
|
||||
|
||||
// distance = base number + extra bits.
|
||||
//
|
||||
// TODO: the upper bound isn't right. 0x8000 is a valid distance.
|
||||
var distance u32[..0x7FFF] = (table_entry >> 8) & 0x7FFF
|
||||
table_entry_n_bits = (table_entry >> 4) & 0x0F
|
||||
if table_entry_n_bits > 0 {
|
||||
@@ -172,6 +174,9 @@ pri func decoder.decode_huffman_slow?(dst writer1, src reader1)() {
|
||||
bits >>= table_entry_n_bits
|
||||
n_bits -= table_entry_n_bits
|
||||
}
|
||||
if distance <= 0 {
|
||||
return error "internal error: inconsistent Huffman decoder state"
|
||||
}
|
||||
|
||||
var n_copied u32
|
||||
while true {
|
||||
|
||||
Reference in new issue
Block a user