[vlc-commits] demux: wav: stay within riff chunk boundaries (fix #10323)
Francois Cartegnie
git at videolan.org
Mon Jan 6 23:45:00 CET 2014
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Mon Jan 6 23:43:59 2014 +0100| [9f0a91cb7e562fcfb72046b38a5f986c0e1bc0e3] | committer: Francois Cartegnie
demux: wav: stay within riff chunk boundaries (fix #10323)
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=9f0a91cb7e562fcfb72046b38a5f986c0e1bc0e3
---
modules/demux/wav.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/modules/demux/wav.c b/modules/demux/wav.c
index 9a1c3d5..0ac9d5e 100644
--- a/modules/demux/wav.c
+++ b/modules/demux/wav.c
@@ -420,15 +420,20 @@ static int Demux( demux_t *p_demux )
demux_sys_t *p_sys = p_demux->p_sys;
block_t *p_block;
const int64_t i_pos = stream_Tell( p_demux->s );
+ unsigned int i_read_size = p_sys->i_frame_size;
- if( p_sys->i_data_size > 0 &&
- i_pos >= p_sys->i_data_pos + p_sys->i_data_size )
+ if( p_sys->i_data_size > 0 )
{
- /* EOF */
- return 0;
+ int64_t i_end = p_sys->i_data_pos + p_sys->i_data_size;
+ if ( i_pos >= i_end )
+ return 0; /* EOF */
+
+ /* Don't read past data chunk boundary */
+ if ( i_end < i_pos + i_read_size )
+ i_read_size = i_end - i_pos;
}
- if( ( p_block = stream_Block( p_demux->s, p_sys->i_frame_size ) ) == NULL )
+ if( ( p_block = stream_Block( p_demux->s, i_read_size ) ) == NULL )
{
msg_Warn( p_demux, "cannot read data" );
return 0;
More information about the vlc-commits
mailing list