From 8ad3aebfbc65fec8e88dc6b8c09b631e4c845d14 Mon Sep 17 00:00:00 2001 From: Serial <69764315+Serial-ATA@users.noreply.github.com> Date: Tue, 29 Oct 2024 20:46:05 -0400 Subject: [PATCH] WV: Don't allow zero-size blocks --- lofty/src/wavpack/properties.rs | 4 ++++ lofty/tests/fuzz/assets/wavpackfile_read_from/bb | Bin 0 -> 123 bytes lofty/tests/fuzz/wavpackfile_read_from.rs | 6 ++++++ 3 files changed, 10 insertions(+) create mode 100644 lofty/tests/fuzz/assets/wavpackfile_read_from/bb diff --git a/lofty/src/wavpack/properties.rs b/lofty/src/wavpack/properties.rs index 255c7c89..f2363999 100644 --- a/lofty/src/wavpack/properties.rs +++ b/lofty/src/wavpack/properties.rs @@ -322,6 +322,10 @@ fn get_extended_meta_info( index += 2; } + if size == 0 { + decode_err!(@BAIL WavPack, "Encountered a zero-sized block"); + } + if id & ID_FLAG_ODD_SIZE > 0 { size -= 1; } diff --git a/lofty/tests/fuzz/assets/wavpackfile_read_from/bb b/lofty/tests/fuzz/assets/wavpackfile_read_from/bb new file mode 100644 index 0000000000000000000000000000000000000000..01457ab6452ae0ba107c23f1ab45658e99833528 GIT binary patch literal 123 ucmXRfE66Tp0D=+_!O)5TAOHXV-wGBal}Kk`NMvB}VQ@y*2sPXrLIVJrzZE?I literal 0 HcmV?d00001 diff --git a/lofty/tests/fuzz/wavpackfile_read_from.rs b/lofty/tests/fuzz/wavpackfile_read_from.rs index 8419de7e..dca46f7f 100644 --- a/lofty/tests/fuzz/wavpackfile_read_from.rs +++ b/lofty/tests/fuzz/wavpackfile_read_from.rs @@ -90,3 +90,9 @@ fn panic1() { let mut reader = crate::get_reader("wavpackfile_read_from/output"); let _ = WavPackFile::read_from(&mut reader, ParseOptions::default()); } + +#[test_log::test] +fn panic2() { + let mut reader = crate::get_reader("wavpackfile_read_from/bb"); + let _ = WavPackFile::read_from(&mut reader, ParseOptions::default()); +}