Changeset 8632e67b53ba6aefa42d080668eaa13dcfe42cf1

Show
Ignore:
Timestamp:
03/02/08 09:48:28 (2 months ago)
Author:
Rémi Denis-Courmont <rem@videolan.org>
git-committer:
Rémi Denis-Courmont <rem@videolan.org> 1204447708 +0200
git-parent:

[09572892df7e72c0d4e598c0b5e076cf330d8b0a]

git-author:
Rémi Denis-Courmont <rem@videolan.org> 1204403550 +0200
Message:

Fix (trunk-only) integer underflow in MP4 0xa9xxx box

Pointed-out-by: Drew Yao
Signed-off-by: Rémi Denis-Courmont <rem@videolan.org>

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/demux/mp4/libmp4.c

    r0957289 r8632e67  
    21162116static int MP4_ReadBox_0xa9xxx( stream_t *p_stream, MP4_Box_t *p_box ) 
    21172117{ 
    2118     uint16_t i_length, i_dummy; 
     2118    uint16_t i16; 
     2119    size_t i_length; 
    21192120 
    21202121    MP4_READBOX_ENTER( MP4_Box_data_0xa9xxx_t ); 
     
    21222123    p_box->data.p_0xa9xxx->psz_text = NULL; 
    21232124 
    2124     MP4_GET2BYTES( i_length ); 
     2125    MP4_GET2BYTES( i16 ); 
     2126    i_length = i16 + 1; 
    21252127 
    21262128    if( i_length > 0 ) 
    21272129    { 
    2128         MP4_GET2BYTES( i_dummy ); 
    2129         if( i_length > i_read ) i_length = i_read; 
    2130  
    2131         p_box->data.p_0xa9xxx->psz_text = malloc( i_length + 1 ); 
    2132  
     2130        MP4_GET2BYTES( i16 ); 
     2131        if( i_length >= i_read ) i_length = i_read + 1; 
     2132 
     2133        p_box->data.p_0xa9xxx->psz_text = malloc( i_length ); 
     2134 
     2135        i_length--; 
    21332136        memcpy( p_box->data.p_0xa9xxx->psz_text, 
    21342137                p_peek, i_length ); 
     
    21612164            MP4_GET4BYTES( i_reserved ); 
    21622165            // version should be 0, flags should be 1 for text, 0 for data 
    2163             if( i_version == 0x00000001
     2166            if( ( i_version == 0x00000001 ) && (i_data_len >= 12 )
    21642167            { 
    21652168                // the rest is the text