From: Kostya Shishkov Date: Thu, 8 Jun 2017 16:05:26 +0000 (+0200) Subject: avi: skip list chunks correctly X-Git-Url: https://git.nihav.org/?a=commitdiff_plain;h=f149a5b7c236d8ab88daca8417a0cc95dda4edfc;p=nihav.git avi: skip list chunks correctly --- diff --git a/src/demuxers/avi.rs b/src/demuxers/avi.rs index 2a3f8f0..2d2a261 100644 --- a/src/demuxers/avi.rs +++ b/src/demuxers/avi.rs @@ -139,7 +139,8 @@ impl<'a> AVIDemuxer<'a> { if RIFFTag::Chunk(tag) == end_tag { return Ok((size, true)); } - let ltag = if is_list_tag(tag) { self.src.read_u32be()? } else { 0 }; + let is_list = is_list_tag(tag); + let ltag = if is_list { self.src.read_u32be()? } else { 0 }; if RIFFTag::List(tag, ltag) == end_tag { return Ok((size, true)); } @@ -170,7 +171,12 @@ impl<'a> AVIDemuxer<'a> { return Ok((size + 8, false)); } } - self.src.read_skip(size)?; + if !is_list { + self.src.read_skip(size)?; + } else { + if size < 4 { return Err(InvalidData); } + self.src.read_skip(size - 4)?; + } if (size & 1) == 1 { self.src.read_skip(1)?; } return Ok((size + 8, false)); }