Commit 38017791 authored by Francois Cartegnie's avatar Francois Cartegnie

demux: libmp4: enforce bounds reading container

parent 3b82206f
...@@ -244,6 +244,8 @@ static int MP4_ReadBoxContainerChildrenIndexed( stream_t *p_stream, ...@@ -244,6 +244,8 @@ static int MP4_ReadBoxContainerChildrenIndexed( stream_t *p_stream,
return 0; return 0;
} }
off_t i_end = p_container->i_pos + p_container->i_size;
do do
{ {
uint32_t i_index = 0; uint32_t i_index = 0;
...@@ -254,12 +256,16 @@ static int MP4_ReadBoxContainerChildrenIndexed( stream_t *p_stream, ...@@ -254,12 +256,16 @@ static int MP4_ReadBoxContainerChildrenIndexed( stream_t *p_stream,
return 0; return 0;
i_index = GetDWBE(&read[4]); i_index = GetDWBE(&read[4]);
} }
if( ( p_box = MP4_ReadBox( p_stream, p_container ) ) == NULL ) continue; if( ( p_box = MP4_ReadBox( p_stream, p_container ) ) == NULL )
break;
p_box->i_index = i_index; p_box->i_index = i_index;
/* chain this box with the father and the other at same level */ /* chain this box with the father and the other at same level */
MP4_BoxAddChild( p_container, p_box ); MP4_BoxAddChild( p_container, p_box );
if( p_container->i_size && stream_Tell( p_stream ) == i_end )
break;
if( p_box->i_type == i_last_child ) if( p_box->i_type == i_last_child )
{ {
MP4_NextBox( p_stream, p_box ); MP4_NextBox( p_stream, p_box );
...@@ -268,6 +274,9 @@ static int MP4_ReadBoxContainerChildrenIndexed( stream_t *p_stream, ...@@ -268,6 +274,9 @@ static int MP4_ReadBoxContainerChildrenIndexed( stream_t *p_stream,
} while( MP4_NextBox( p_stream, p_box ) == 1 ); } while( MP4_NextBox( p_stream, p_box ) == 1 );
if ( p_container->i_size && stream_Tell( p_stream ) != i_end )
MP4_Seek( p_stream, i_end );
return 1; return 1;
} }
......
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