Skip to content

Commit 5a3a8ba

Browse files
committed
Vorbis: Check comment counts before allocation
1 parent 2a7c061 commit 5a3a8ba

File tree

4 files changed

+13
-1
lines changed

4 files changed

+13
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3131
- **WAV**:
3232
- Fix panic when reading properties with large written bytes per second ([issue](https://github.com/Serial-ATA/lofty-rs/issues/420))
3333
- Fix panic when reading an improperly sized INFO LIST ([issue](https://github.com/Serial-ATA/lofty-rs/issues/427))
34-
- **Vorbis**: Fix panic when reading properties of a file with large absolute granule positions ([issue](https://github.com/Serial-ATA/lofty-rs/issues/421))
34+
- **Vorbis**:
35+
- Fix panic when reading properties of a file with large absolute granule positions ([issue](https://github.com/Serial-ATA/lofty-rs/issues/421))
36+
- Fix attempted large allocations with invalid comment counts ([issue](https://github.com/Serial-ATA/lofty-rs/issues/419))
3537
- **FLAC**: Fix panic when reading properties of a file with incorrect block sizes ([issue](https://github.com/Serial-ATA/lofty-rs/issues/422))
3638
- **AIFF**: Fix panic when reading properties of a file with invalid f80 sample rate ([issue](https://github.com/Serial-ATA/lofty-rs/issues/424))
3739

lofty/src/ogg/read.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ where
7575
};
7676

7777
let number_of_items = data.read_u32::<LittleEndian>()?;
78+
if number_of_items > (len >> 2) as u32 {
79+
err!(SizeMismatch);
80+
}
7881

7982
let mut tag = VorbisComments {
8083
vendor,
Binary file not shown.

lofty/tests/fuzz/vorbisfile_read_from.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@ fn oom1() {
88
oom_test::<VorbisFile>("vorbisfile_read_from/oom-436193bc2d1664b74c19720bef08697d03284f06");
99
}
1010

11+
#[test]
12+
fn large_allocation() {
13+
let mut reader =
14+
crate::get_reader("vorbisfile_read_from/move01d_IDX_13_RAND_35154275996070165946691.ogg");
15+
let _ = VorbisFile::read_from(&mut reader, ParseOptions::new());
16+
}
17+
1118
#[test]
1219
fn panic1() {
1320
let mut reader =

0 commit comments

Comments
 (0)