Skip to content

Commit 21b1db4

Browse files
committed
Report format error when order > frame length
A file where this happens is invalid. Instead of causing an index out of bounds, this should report an error. Fortunately this is Rust, which panics on out of bounds indexing, instead of C which would have had an out of bounds read. Found using libfuzzer and cargo-fuzz.
1 parent 483eda3 commit 21b1db4

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/subframe.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,13 @@ fn decode_lpc<R: ReadBytes>(input: &mut Bitstream<R>,
583583
// The order minus one fits in 5 bits, so the order is at most 32.
584584
debug_assert!(order <= 32);
585585

586+
// On the frame decoding level it is ensured that the buffer is large
587+
// enough. If it can't even fit the warm-up samples, then there is a frame
588+
// smaller than its lpc order, which is invalid.
589+
if buffer.len() < order as usize {
590+
return fmt_err("invalid subframe, buffer is too small for given lpc order")
591+
}
592+
586593
// There are order * bits per sample unencoded warm-up sample bits.
587594
try!(decode_verbatim(input, bps, &mut buffer[..order as usize]));
588595

177 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)