From 82acd9e0ed5d8e2d1e229958d19523a155d03f08 Mon Sep 17 00:00:00 2001 From: Serial <69764315+Serial-ATA@users.noreply.github.com> Date: Fri, 24 Nov 2023 14:10:50 -0500 Subject: [PATCH] EBML: Make use of `max_id_length` when reading Signed-off-by: Serial <69764315+Serial-ATA@users.noreply.github.com> --- src/ebml/element_reader.rs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/ebml/element_reader.rs b/src/ebml/element_reader.rs index 121f9d1e..b71356fa 100644 --- a/src/ebml/element_reader.rs +++ b/src/ebml/element_reader.rs @@ -13,12 +13,12 @@ pub struct ElementHeader { } impl ElementHeader { - fn read(reader: &mut R, max_vint_length: u8) -> Result + fn read(reader: &mut R, max_id_length: u8, max_vint_length: u8) -> Result where R: Read, { Ok(Self { - id: VInt::parse(reader, max_vint_length)?, + id: VInt::parse(reader, max_id_length)?, size: VInt::parse(reader, max_vint_length)?, }) } @@ -141,7 +141,11 @@ where } fn next_master(&mut self) -> Result { - let header = ElementHeader::read(&mut self.reader, self.ctx.max_size_length)?; + let header = ElementHeader::read( + &mut self.reader, + self.ctx.max_id_length, + self.ctx.max_size_length, + )?; let Some(master) = MASTER_ELEMENTS.get(&header.id) else { // We encountered an unknown master element return Ok(ElementReaderYield::Unknown(header)); @@ -164,7 +168,11 @@ where return self.next_master(); } - let header = ElementHeader::read(&mut self.reader, self.ctx.max_size_length)?; + let header = ElementHeader::read( + &mut self.reader, + self.ctx.max_id_length, + self.ctx.max_size_length, + )?; let Some((_, child)) = current_master .children