From 6132225fee0729a31cce37fc67c3be47ec6d2e79 Mon Sep 17 00:00:00 2001 From: Kostya Shishkov Date: Sun, 4 Feb 2018 18:50:20 +0100 Subject: [PATCH] realmedia: break on zero ID chunk --- src/demuxers/realmedia.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/demuxers/realmedia.rs b/src/demuxers/realmedia.rs index 7ff27ba..f8d5a3e 100644 --- a/src/demuxers/realmedia.rs +++ b/src/demuxers/realmedia.rs @@ -297,6 +297,7 @@ println!(" mode 3"); fn read_chunk(src: &mut ByteReader) -> DemuxerResult<(u32, u32, u16)> { let id = src.read_u32be()?; +if id == 0 { return Ok((0, 0, 0)); } let size = src.read_u32be()?; validate!(size >= 10); let ver = src.read_u16be()?; @@ -353,7 +354,8 @@ impl<'a> RealMediaDemuxer<'a> { } for _ in 0..num_hdr { - self.parse_chunk(strmgr)?; + let last = self.parse_chunk(strmgr)?; + if last { break; } } println!("now @ {:X} / {}", self.src.tell(), self.data_pos); validate!(self.data_pos > 0); @@ -364,7 +366,7 @@ println!("now @ {:X} / {}", self.src.tell(), self.data_pos); self.cur_packet = 0; Ok(()) } - fn parse_chunk(&mut self, strmgr: &mut StreamManager) -> DemuxerResult<()> { + fn parse_chunk(&mut self, strmgr: &mut StreamManager) -> DemuxerResult { let (id, size, ver) = read_chunk(self.src)?; let end_pos = self.src.tell() - 10 + (size as u64); @@ -373,13 +375,14 @@ println!("now @ {:X} / {}", self.src.tell(), self.data_pos); else if id == mktag!(b"MDPR") { self.parse_mdpr(strmgr)?; } else if id == mktag!(b"DATA") { if self.data_pos == 0 { self.data_pos = self.src.tell(); } } else if id == mktag!(b"INDX") { /* do nothing for now */ } + else if id == 0 { return Ok(true); } else { println!("unknown chunk type {:08X}", id); } let cpos = self.src.tell(); if cpos < end_pos { self.src.read_skip((end_pos - cpos) as usize)?; } - Ok(()) + Ok(false) } #[allow(unused_variables)] fn parse_content_desc(&mut self) -> DemuxerResult<()> { -- 2.39.5