vlc | branch: master | Francois Cartegnie <[email protected]> | Thu Aug 16 11:33:59 2018 +0200| [6b00be9e5e60aaf2d52855152395dd44c1c54a39] | committer: Francois Cartegnie
demux: mp4: handle moof to mdat gap (fix #21028) > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=6b00be9e5e60aaf2d52855152395dd44c1c54a39 --- modules/demux/mp4/mp4.c | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/modules/demux/mp4/mp4.c b/modules/demux/mp4/mp4.c index 5bdab8766e..7c904a89d0 100644 --- a/modules/demux/mp4/mp4.c +++ b/modules/demux/mp4/mp4.c @@ -4948,19 +4948,38 @@ static int DemuxFrag( demux_t *p_demux ) } p_sys->context.i_current_box_type = VLC_FOURCC( p_peek[4], p_peek[5], p_peek[6], p_peek[7] ); - if( p_sys->context.i_current_box_type == ATOM_mdat ) + if( p_sys->context.i_current_box_type != ATOM_moof && + p_sys->context.i_current_box_type != ATOM_moov ) { - uint64_t size = GetDWBE( p_peek ); - if ( size == 1 ) + uint64_t i_pos = vlc_stream_Tell( p_demux->s ); + uint64_t i_size = GetDWBE( p_peek ); + if ( i_size == 1 ) { if( vlc_stream_Peek( p_demux->s, &p_peek, 16 ) != 16 ) { i_status = VLC_DEMUXER_EOF; goto end; } - size = GetQWBE( p_peek + 8 ); + i_size = GetQWBE( p_peek + 8 ); + } + + if( UINT64_MAX - i_pos < i_size ) + { + i_status = VLC_DEMUXER_EOF; + goto end; + } + + if( p_sys->context.i_current_box_type == ATOM_mdat ) + { + /* We'll now read mdat using context atom, + * but we'll need post mdat offset, as we'll never seek backward */ + p_sys->context.i_post_mdat_offset = i_pos + i_size; + } + else if( MP4_Seek( p_demux->s, i_pos + i_size ) != VLC_SUCCESS ) /* skip other atoms */ + { + i_status = VLC_DEMUXER_EOF; + goto end; } - p_sys->context.i_post_mdat_offset = vlc_stream_Tell( p_demux->s ) + size; } else { _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
