[vlc-commits] demux: avi: handle zero sized strd sections (fix #8994)

Francois Cartegnie git at videolan.org
Sat Aug 24 12:28:33 CEST 2013


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Fri Aug 23 18:36:36 2013 +0200| [e0e03582378dc7df8b37e3fb01c4d1aaeccd437b] | committer: Francois Cartegnie

demux: avi: handle zero sized strd sections (fix #8994)

Sunplus chipset based cameras creates those zero sized proprietary
sections.

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

 modules/demux/avi/libavi.c |   14 +++++++++++++-
 modules/demux/avi/libavi.h |    1 +
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/modules/demux/avi/libavi.c b/modules/demux/avi/libavi.c
index 80f0f84..c09175f 100644
--- a/modules/demux/avi/libavi.c
+++ b/modules/demux/avi/libavi.c
@@ -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' ) ||
diff --git a/modules/demux/avi/libavi.h b/modules/demux/avi/libavi.h
index 917bfb6..1ef830c 100644
--- a/modules/demux/avi/libavi.h
+++ b/modules/demux/avi/libavi.h
@@ -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



More information about the vlc-commits mailing list