Commit 397df13c authored by Laurent Aimar's avatar Laurent Aimar

Do not read the whole file (in memory !) when parsing RAR.

parent 7f581337
......@@ -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 )
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment