[vlc-devel] commit: Do not read the whole file (in memory !) when parsing RAR. ( Laurent Aimar )
git version control
git at videolan.org
Mon May 4 21:02:56 CEST 2009
vlc | branch: master | Laurent Aimar <fenrir at videolan.org> | Mon May 4 20:47:32 2009 +0200| [397df13cacbc11d2b164106b7f357b637d13f60e] | committer: Laurent Aimar
Do not read the whole file (in memory !) when parsing RAR.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=397df13cacbc11d2b164106b7f357b637d13f60e
---
modules/stream_filter/rar.c | 14 +++++++++++---
1 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/modules/stream_filter/rar.c b/modules/stream_filter/rar.c
index 791e12f..a5fd829 100644
--- a/modules/stream_filter/rar.c
+++ b/modules/stream_filter/rar.c
@@ -442,15 +442,15 @@ static int SkipFile( stream_t *s,const rar_block_t *p_hdr )
stream_sys_t *p_sys = s->p_sys;
const uint8_t *p_peek;
- if( stream_Peek( s->p_source, &p_peek, p_hdr->i_size ) < p_hdr->i_size )
- return VLC_EGENERIC;
-
int i_min_size = 7+21;
if( p_hdr->i_flags & RAR_BLOCK_FILE_HAS_HIGH )
i_min_size += 8;
if( p_hdr->i_size < i_min_size )
return VLC_EGENERIC;
+ if( stream_Peek( s->p_source, &p_peek, i_min_size ) < i_min_size )
+ return VLC_EGENERIC;
+
/* */
uint32_t i_file_size_low = GetDWLE( &p_peek[7+4] );
uint8_t i_method = p_peek[7+18];
@@ -465,7 +465,15 @@ static int SkipFile( stream_t *s,const rar_block_t *p_hdr )
const int i_name_offset = (p_hdr->i_flags & RAR_BLOCK_FILE_HAS_HIGH) ? (7+33) : (7+25);
if( i_name_offset + i_name_size <= p_hdr->i_size )
+ {
+ const int i_max_size = i_name_offset + i_name_size;
+ if( stream_Peek( s->p_source, &p_peek, i_max_size ) < i_max_size )
+ {
+ free( psz_name );
+ return VLC_EGENERIC;
+ }
memcpy( psz_name, &p_peek[i_name_offset], i_name_size );
+ }
if( i_method != 0x30 )
{
More information about the vlc-devel
mailing list