mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-20 00:47:28 +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
@@ -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