[vlc-commits] demux: avi: fix potential invalid deref on seek
Francois Cartegnie
git at videolan.org
Tue Jan 30 14:41:30 CET 2018
vlc/vlc-3.0 | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Tue Jan 30 13:31:37 2018 +0100| [c89b833548ab761e9129447d57ea8add1ed5c148] | committer: Francois Cartegnie
demux: avi: fix potential invalid deref on seek
(cherry picked from commit 85171d7fd2c704c733b47e686ba1e2285eb2eea7)
> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=c89b833548ab761e9129447d57ea8add1ed5c148
---
modules/demux/avi/avi.c | 32 +++++++++++++-------------------
1 file changed, 13 insertions(+), 19 deletions(-)
diff --git a/modules/demux/avi/avi.c b/modules/demux/avi/avi.c
index 4cc3882dcc..2aff14b4be 100644
--- a/modules/demux/avi/avi.c
+++ b/modules/demux/avi/avi.c
@@ -1856,37 +1856,31 @@ static mtime_t AVI_GetDPTS( avi_track_t *tk, int64_t i_count )
static mtime_t AVI_GetPTS( avi_track_t *tk )
{
- if( tk->i_samplesize )
+ /* Lookup samples index */
+ if( tk->i_samplesize && tk->idx.i_size )
{
int64_t i_count = 0;
+ unsigned int idx = tk->i_idxposc;
/* we need a valid entry we will emulate one */
- if( tk->i_idxposc == tk->idx.i_size )
+ if( idx >= tk->idx.i_size )
{
- if( tk->i_idxposc )
- {
- /* use the last entry */
- i_count = tk->idx.p_entry[tk->idx.i_size - 1].i_lengthtotal
- + tk->idx.p_entry[tk->idx.i_size - 1].i_length;
- }
+ /* use the last entry */
+ idx = tk->idx.i_size - 1;
+ i_count = tk->idx.p_entry[idx].i_lengthtotal
+ + tk->idx.p_entry[idx].i_length;
}
else
{
- i_count = tk->idx.p_entry[tk->i_idxposc].i_lengthtotal;
+ i_count = tk->idx.p_entry[idx].i_lengthtotal;
}
return AVI_GetDPTS( tk, i_count + tk->i_idxposb );
}
+
+ if( tk->fmt.i_cat == AUDIO_ES )
+ return AVI_GetDPTS( tk, tk->i_blockno );
else
- {
- if( tk->fmt.i_cat == AUDIO_ES )
- {
- return AVI_GetDPTS( tk, tk->i_blockno );
- }
- else
- {
- return AVI_GetDPTS( tk, tk->i_idxposc );
- }
- }
+ return AVI_GetDPTS( tk, tk->i_idxposc );
}
static int AVI_StreamChunkFind( demux_t *p_demux, unsigned int i_stream )
More information about the vlc-commits
mailing list