]> git.sesse.net Git - vlc/commitdiff
demux: avi: handle zero sized strd sections (fix #8994)
authorFrancois Cartegnie <fcvlcdev@free.fr>
Fri, 23 Aug 2013 16:36:36 +0000 (18:36 +0200)
committerFrancois Cartegnie <fcvlcdev@free.fr>
Sat, 24 Aug 2013 10:27:49 +0000 (12:27 +0200)
Sunplus chipset based cameras creates those zero sized proprietary
sections.

modules/demux/avi/libavi.c
modules/demux/avi/libavi.h

index 80f0f84801486edb630b2f5c59944247a64256f9..c09175f47f51193f31571983dbfade4d5408331a 100644 (file)
@@ -446,6 +446,12 @@ static void AVI_ChunkFree_strf( avi_chunk_t *p_chk )
 
 static int AVI_ChunkRead_strd( stream_t *s, avi_chunk_t *p_chk )
 {
+    if ( p_chk->common.i_chunk_size == 0 )
+    {
+        msg_Dbg( (vlc_object_t*)s, "Zero sized pre-JUNK section met" );
+        return AVI_STRD_ZERO_CHUNK;
+    }
+
     AVI_READCHUNK_ENTER;
     p_chk->strd.p_data = xmalloc( p_chk->common.i_chunk_size );
     memcpy( p_chk->strd.p_data, p_buff + 8, p_chk->common.i_chunk_size );
@@ -832,7 +838,13 @@ int  AVI_ChunkRead( stream_t *s, avi_chunk_t *p_chk, avi_chunk_t *p_father )
     i_index = AVI_ChunkFunctionFind( p_chk->common.i_chunk_fourcc );
     if( AVI_Chunk_Function[i_index].AVI_ChunkRead_function )
     {
-        return AVI_Chunk_Function[i_index].AVI_ChunkRead_function( s, p_chk );
+        int i_return = AVI_Chunk_Function[i_index].AVI_ChunkRead_function( s, p_chk );
+        if ( i_return == AVI_STRD_ZERO_CHUNK )
+        {
+            if ( !p_father ) return VLC_EGENERIC;
+            return AVI_NextChunk( s, p_father );
+        }
+        return i_return;
     }
     else if( ( ((char*)&p_chk->common.i_chunk_fourcc)[0] == 'i' &&
                ((char*)&p_chk->common.i_chunk_fourcc)[1] == 'x' ) ||
index 917bfb63ffd4fe0c69a5afa98c168d4b15532608..1ef830cb15af4c59ade3c41ab8c673f4e9895ded 100644 (file)
@@ -178,6 +178,7 @@ typedef struct avi_chunk_dmlh_s
     uint32_t dwTotalFrames;
 } avi_chunk_dmlh_t;
 
+#define AVI_STRD_ZERO_CHUNK     0xFF
 
 #define AVI_INDEX_OF_INDEXES    0x00
 #define AVI_INDEX_OF_CHUNKS     0x01