vlc | branch: master | Francois Cartegnie <fcvlc...@free.fr> | Mon Oct 13 
22:57:17 2014 +0200| [77b824231c2b844bf76d02f2f66bb6bce724d00e] | committer: 
Francois Cartegnie

demux: libmp4: enforce handler check on meta atom

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=77b824231c2b844bf76d02f2f66bb6bce724d00e
---

 modules/demux/mp4/libmp4.c |   34 ++++++++++++++--------------------
 1 file changed, 14 insertions(+), 20 deletions(-)

diff --git a/modules/demux/mp4/libmp4.c b/modules/demux/mp4/libmp4.c
index e497541..2c2a589 100644
--- a/modules/demux/mp4/libmp4.c
+++ b/modules/demux/mp4/libmp4.c
@@ -3100,33 +3100,27 @@ static int MP4_ReadBox_meta( stream_t *p_stream, 
MP4_Box_t *p_box )
     if( i_actually_read < 8 )
         return 0;
 
-    if ( !p_box->p_father )
-        return 0;
-
-    switch( p_box->p_father->i_type )
+    if ( p_box->p_father && p_box->p_father->i_type == ATOM_udta ) /* itunes 
udta/meta */
     {
-    case ATOM_udta: /* itunes udta/meta */
         /* meta content starts with a 4 byte version/flags value (should be 0) 
*/
         i_actually_read = stream_Read( p_stream, meta_data, 4 );
-        if( i_actually_read < 4 )
+        if( i_actually_read < 4 || memcmp( meta_data, "\0\0\0", 4 ) )
             return 0;
+    }
 
-        /* then it behaves like a container */
-        return MP4_ReadBoxContainerRaw( p_stream, p_box );
-
-    default: /* regular meta atom */
-
-        i_actually_read = stream_Read( p_stream, meta_data, 8 );
-        if( i_actually_read < 8 )
-            return 0;
+    if ( !MP4_ReadBoxContainerChildren( p_stream, p_box, ATOM_hdlr ) )
+        return 0;
 
-        /* Mandatory */
-        if ( VLC_FOURCC( meta_data[4], meta_data[5], meta_data[6], 
meta_data[7] ) != ATOM_hdlr )
-            return 0;
+    /* Mandatory */
+    const MP4_Box_t *p_hdlr = MP4_BoxGet( p_box, "hdlr" );
+    if ( !p_hdlr || !BOXDATA(p_hdlr) ||
+         ( BOXDATA(p_hdlr)->i_handler_type != VLC_FOURCC('m', 'd', 't', 'a') &&
+           BOXDATA(p_hdlr)->i_handler_type != VLC_FOURCC('m', 'd', 'i', 'r') ) 
||
+         BOXDATA(p_hdlr)->i_version != 0 )
+        return 0;
 
-        //ft
-    }
-    return 1;
+    /* then it behaves like a container */
+    return MP4_ReadBoxContainerRaw( p_stream, p_box );
 }
 
 static int MP4_ReadBox_iods( stream_t *p_stream, MP4_Box_t *p_box )

_______________________________________________
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits

Reply via email to