[vlc-commits] [Git][videolan/vlc][3.0.x] demux: avi: add recursion limit
Jean-Baptiste Kempf (@jbk)
gitlab at videolan.org
Sun Nov 15 20:30:03 UTC 2026
Jean-Baptiste Kempf pushed to branch 3.0.x at VideoLAN / VLC
Commits:
fb916cd7 by François Cartegnie at 2026-11-15T21:10:20+01:00
demux: avi: add recursion limit
refs #30101
(adapted from commit 4f411065d6ff7ec898026a7a0cf2d672b799a52b)
- - - - -
3 changed files:
- modules/demux/avi/avi.c
- modules/demux/avi/libavi.c
- modules/demux/avi/libavi.h
Changes:
=====================================
modules/demux/avi/avi.c
=====================================
@@ -3106,7 +3106,7 @@ static void AVI_ExtractSubtitle( demux_t *p_demux,
avi_chunk_indx_t *p_indx = NULL;
avi_chunk_t ck;
- AVI_ChunkInit( &ck );
+ AVI_ChunkInit( &ck, p_strl->i_depth + 1 );
int64_t i_position;
unsigned i_size;
=====================================
modules/demux/avi/libavi.c
=====================================
@@ -38,6 +38,7 @@
#endif
#define __EVEN( x ) (((x) + 1) & ~1)
+#define AVI_MAX_DEPTH 32
static vlc_fourcc_t GetFOURCC( const uint8_t *p_buff )
{
@@ -60,11 +61,11 @@ static uint64_t AVI_ChunkEnd( const avi_chunk_t *p_ck )
*
****************************************************************************/
static int AVI_ChunkReadCommon( stream_t *s, avi_chunk_t *p_chk,
- const avi_chunk_t *p_father )
+ const avi_chunk_t *p_father, unsigned i_depth )
{
const uint8_t *p_peek;
- AVI_ChunkInit( p_chk );
+ AVI_ChunkInit( p_chk, i_depth );
const uint64_t i_pos = vlc_stream_Tell( s );
if( vlc_stream_Peek( s, &p_peek, 8 ) < 8 )
@@ -129,7 +130,7 @@ static int AVI_NextChunk( stream_t *s, avi_chunk_t *p_chk )
if( !p_chk )
{
- if( AVI_ChunkReadCommon( s, &chk, NULL ) )
+ if( AVI_ChunkReadCommon( s, &chk, NULL, 0 ) )
{
return VLC_EGENERIC;
}
@@ -981,13 +982,17 @@ int AVI_ChunkRead( stream_t *s, avi_chunk_t *p_chk, avi_chunk_t *p_father )
{
int i_index;
+ unsigned i_depth = p_father ? p_father->common.i_depth + 1 : 0;
+ if( i_depth >= AVI_MAX_DEPTH )
+ return VLC_EGENERIC;
+
if( !p_chk )
{
msg_Warn( (vlc_object_t*)s, "cannot read null chunk" );
return VLC_EGENERIC;
}
- if( AVI_ChunkReadCommon( s, p_chk, p_father ) )
+ if( AVI_ChunkReadCommon( s, p_chk, p_father, i_depth ) )
return VLC_EGENERIC;
if( p_chk->common.i_chunk_fourcc == VLC_FOURCC( 0, 0, 0, 0 ) )
@@ -1051,14 +1056,15 @@ void AVI_ChunkClean( stream_t *s,
msg_Warn( (vlc_object_t*)s, "unknown chunk: %4.4s (not unloaded)",
(char*)&p_chk->common.i_chunk_fourcc );
}
- AVI_ChunkInit( p_chk );
+ AVI_ChunkInit( p_chk, 0 );
return;
}
-void AVI_ChunkInit( avi_chunk_t *p_chk )
+void AVI_ChunkInit( avi_chunk_t *p_chk, unsigned i_depth )
{
memset( p_chk, 0, sizeof(*p_chk) );
+ p_chk->common.i_depth = i_depth;
}
static void AVI_ChunkDumpDebug_level( vlc_object_t *p_obj,
@@ -1119,6 +1125,7 @@ int AVI_ChunkReadRoot( stream_t *s, avi_chunk_t *p_root )
p_list->p_father = NULL;
p_list->p_next = NULL;
p_list->p_first = NULL;
+ p_list->i_depth = 0;
p_list->i_type = VLC_FOURCC( 'r', 'o', 'o', 't' );
=====================================
modules/demux/avi/libavi.h
=====================================
@@ -58,7 +58,8 @@
uint64_t i_chunk_pos; \
union avi_chunk_u *p_next; \
union avi_chunk_u *p_father; \
- union avi_chunk_u *p_first;
+ union avi_chunk_u *p_first; \
+ unsigned i_depth;
#define AVI_CHUNK( p_chk ) (avi_chunk_t*)(p_chk)
@@ -252,7 +253,7 @@ int AVI_ChunkRead( stream_t *,
avi_chunk_t *p_chk,
avi_chunk_t *p_father );
void AVI_ChunkClean( stream_t *, avi_chunk_t * );
-void AVI_ChunkInit( avi_chunk_t * );
+void AVI_ChunkInit( avi_chunk_t *, unsigned );
int AVI_ChunkCount_( avi_chunk_t *, vlc_fourcc_t, bool );
void *AVI_ChunkFind_ ( avi_chunk_t *, vlc_fourcc_t, int, bool );
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/fb916cd7cd4381bfa1cb5917d1b7a33a688209d2
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/fb916cd7cd4381bfa1cb5917d1b7a33a688209d2
You're receiving this email because of your account on code.videolan.org. Manage all notifications: https://code.videolan.org/-/profile/notifications | Help: https://code.videolan.org/help
More information about the vlc-commits
mailing list