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

Francois Cartegnie fcvlcdev at free.fr
Fri Aug 23 18:37:45 CEST 2013


Sunplus chipset based cameras create those zero sized proprietary
sections.
---
 modules/demux/avi/libavi.c | 15 ++++++++++++++-
 modules/demux/avi/libavi.h |  1 +
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/modules/demux/avi/libavi.c b/modules/demux/avi/libavi.c
index 80f0f84..c8410b3 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, "JUNK Section found" );
+        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,14 @@ 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 );
+        /* Handle strd alignment sections */
+        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
-- 
1.8.1.4




More information about the vlc-devel mailing list