Skip to content

Commit

Permalink
demux: mp4: fix buffer overflow in parsing of string boxes.
Browse files Browse the repository at this point in the history
We ensure that pbox->i_size is never smaller than 8 to avoid an
integer underflow in the third argument of the subsequent call to
memcpy. We also make sure no truncation occurs when passing values
derived from the 64 bit integer p_box->i_size to arguments of malloc
and memcpy that may be 32 bit integers on 32 bit platforms.

Signed-off-by: Jean-Baptiste Kempf <jb@videolan.org>
  • Loading branch information
Fabian Yamaguchi authored and jbkempf committed Dec 8, 2014
1 parent 2b35d73 commit 2e7c709
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions modules/demux/mp4/libmp4.c
Expand Up @@ -2858,6 +2858,9 @@ static int MP4_ReadBox_String( stream_t *p_stream, MP4_Box_t *p_box )
{
MP4_READBOX_ENTER( MP4_Box_data_string_t );

if( p_box->i_size < 8 || p_box->i_size > SIZE_MAX )
MP4_READBOX_EXIT( 0 );

p_box->data.p_string->psz_text = malloc( p_box->i_size + 1 - 8 ); /* +\0, -name, -size */
if( p_box->data.p_string->psz_text == NULL )
MP4_READBOX_EXIT( 0 );
Expand Down

0 comments on commit 2e7c709

Please sign in to comment.