mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-24 16:52:18 +01:00
std/xz: reset LZMA decoder after first block
Updates https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=66816
This commit is contained in:
1 parent
5ec31fc291
commit
22fd87efc6
2 files changed
+15
-2
No files matched your search
@@ -13933,8 +13933,9 @@ struct wuffs_xz__decoder__struct {
|
|||||||
|
|
||||||
uint32_t f_filters[3];
|
uint32_t f_filters[3];
|
||||||
uint32_t f_num_non_final_filters;
|
uint32_t f_num_non_final_filters;
|
||||||
uint32_t f_checksummer;
|
uint8_t f_checksummer;
|
||||||
bool f_ignore_checksum;
|
bool f_ignore_checksum;
|
||||||
|
bool f_lzma_needs_reset;
|
||||||
bool f_block_has_compressed_size;
|
bool f_block_has_compressed_size;
|
||||||
bool f_block_has_uncompressed_size;
|
bool f_block_has_uncompressed_size;
|
||||||
uint8_t f_bcj_undo_index;
|
uint8_t f_bcj_undo_index;
|
||||||
@@ -68210,6 +68211,7 @@ wuffs_xz__decoder__do_transform_io(
|
|||||||
}
|
}
|
||||||
v_compressed_size += 1u;
|
v_compressed_size += 1u;
|
||||||
}
|
}
|
||||||
|
self->private_impl.f_lzma_needs_reset = true;
|
||||||
if (self->private_impl.f_ignore_checksum) {
|
if (self->private_impl.f_ignore_checksum) {
|
||||||
self->private_data.s_do_transform_io.scratch = ((uint32_t)(WUFFS_XZ__CHECKSUM_LENGTH[self->private_impl.f_checksummer]));
|
self->private_data.s_do_transform_io.scratch = ((uint32_t)(WUFFS_XZ__CHECKSUM_LENGTH[self->private_impl.f_checksummer]));
|
||||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(12);
|
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(12);
|
||||||
@@ -68984,6 +68986,10 @@ wuffs_xz__decoder__decode_block_header_sans_padding(
|
|||||||
v_filter_id = t_8;
|
v_filter_id = t_8;
|
||||||
}
|
}
|
||||||
if (v_filter_id == 33u) {
|
if (v_filter_id == 33u) {
|
||||||
|
if (self->private_impl.f_lzma_needs_reset) {
|
||||||
|
wuffs_private_impl__ignore_status(wuffs_lzma__decoder__initialize(&self->private_data.f_lzma,
|
||||||
|
sizeof (wuffs_lzma__decoder), WUFFS_VERSION, WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED));
|
||||||
|
}
|
||||||
{
|
{
|
||||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(11);
|
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(11);
|
||||||
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
|
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
|
||||||
|
|||||||
@@ -42,10 +42,12 @@ pub struct decoder? implements base.io_transformer(
|
|||||||
// 1: CRC-32.
|
// 1: CRC-32.
|
||||||
// 2: CRC-64.
|
// 2: CRC-64.
|
||||||
// 3: SHA-256.
|
// 3: SHA-256.
|
||||||
checksummer : base.u32[..= 3],
|
checksummer : base.u8[..= 3],
|
||||||
|
|
||||||
ignore_checksum : base.bool,
|
ignore_checksum : base.bool,
|
||||||
|
|
||||||
|
lzma_needs_reset : base.bool,
|
||||||
|
|
||||||
block_has_compressed_size : base.bool,
|
block_has_compressed_size : base.bool,
|
||||||
block_has_uncompressed_size : base.bool,
|
block_has_uncompressed_size : base.bool,
|
||||||
|
|
||||||
@@ -327,6 +329,8 @@ pri func decoder.do_transform_io?(dst: base.io_writer, src: base.io_reader, work
|
|||||||
compressed_size ~mod+= 1
|
compressed_size ~mod+= 1
|
||||||
} endwhile
|
} endwhile
|
||||||
|
|
||||||
|
this.lzma_needs_reset = true
|
||||||
|
|
||||||
if this.ignore_checksum {
|
if this.ignore_checksum {
|
||||||
args.src.skip_u32?(n: CHECKSUM_LENGTH[this.checksummer] as base.u32)
|
args.src.skip_u32?(n: CHECKSUM_LENGTH[this.checksummer] as base.u32)
|
||||||
|
|
||||||
@@ -598,6 +602,9 @@ pri func decoder.decode_block_header_sans_padding?(src: base.io_reader) {
|
|||||||
|
|
||||||
filter_id = args.src.read_u8?()
|
filter_id = args.src.read_u8?()
|
||||||
if filter_id == 0x21 { // LZMA2
|
if filter_id == 0x21 { // LZMA2
|
||||||
|
if this.lzma_needs_reset {
|
||||||
|
this.lzma.reset!()
|
||||||
|
}
|
||||||
// LZMA2's "Size of Properties" should be 1.
|
// LZMA2's "Size of Properties" should be 1.
|
||||||
c8 = args.src.read_u8?()
|
c8 = args.src.read_u8?()
|
||||||
if c8 <> 0x01 {
|
if c8 <> 0x01 {
|
||||||
|
|||||||
Reference in new issue
Block a user