From: Kostya Shishkov Date: Sun, 4 Jun 2017 12:38:24 +0000 (+0200) Subject: AVI: align parsed chunks X-Git-Url: https://git.nihav.org/?a=commitdiff_plain;h=f6fa6f3404393e399a05c5d5cda7a35c4e41fb4a;p=nihav.git AVI: align parsed chunks --- diff --git a/src/demuxers/avi.rs b/src/demuxers/avi.rs index 56cf023..2a3f8f0 100644 --- a/src/demuxers/avi.rs +++ b/src/demuxers/avi.rs @@ -148,6 +148,7 @@ impl<'a> AVIDemuxer<'a> { if RIFFTag::Chunk(tag) == CHUNKS[i].tag { let psize = (CHUNKS[i].parse)(self, size)?; if psize != size { return Err(InvalidData); } + if (psize & 1) == 1 { self.src.read_skip(1)?; } return Ok((size + 8, false)); } if RIFFTag::List(tag, ltag) == CHUNKS[i].tag { @@ -159,12 +160,18 @@ impl<'a> AVIDemuxer<'a> { let (psize, _) = self.parse_chunk(end_tag, rest_size, depth+1)?; if psize > rest_size { return Err(InvalidData); } rest_size -= psize; + if (psize & 1) == 1 { + if rest_size > 0 { + rest_size -= 1; + } + } } return Ok((size + 8, false)); } } self.src.read_skip(size)?; + if (size & 1) == 1 { self.src.read_skip(1)?; } return Ok((size + 8, false)); }