[vlc-commits] [Git][videolan/vlc][3.0.x] demux: asf: limit recursion depth
Jean-Baptiste Kempf (@jbk)
gitlab at videolan.org
Sun Nov 15 20:07:47 UTC 2026
Jean-Baptiste Kempf pushed to branch 3.0.x at VideoLAN / VLC
Commits:
6b24ce03 by François Cartegnie at 2026-11-15T20:58:54+01:00
demux: asf: limit recursion depth
refs #30101
(adapted from commit bdb00cdcdfd76e41ddd3502b34540fa4941ba100)
- - - - -
2 changed files:
- modules/demux/asf/libasf.c
- modules/demux/asf/libasf.h
Changes:
=====================================
modules/demux/asf/libasf.c
=====================================
@@ -36,6 +36,8 @@
# define ASF_DEBUG 1
#endif
+#define ASF_MAX_DEPTH 32
+
/* Helpers:
* They ensure that invalid reads will not create problems.
* They are expansion safe
@@ -106,11 +108,13 @@ static char *AsfObjectHelperReadString( const uint8_t *p_peek, size_t i_peek, ui
*
****************************************************************************/
static int ASF_ReadObject( stream_t *, asf_object_t *, asf_object_t * );
+static int ASF_ReadObjectExpDepth( stream_t *, asf_object_t *,
+ asf_object_t *, unsigned );
/****************************************************************************
*
****************************************************************************/
-static int ASF_ReadObjectCommon( stream_t *s, asf_object_t *p_obj )
+static int ASF_ReadObjectCommon( stream_t *s, asf_object_t *p_obj, unsigned i_level )
{
asf_object_common_t *p_common = &p_obj->common;
const uint8_t *p_peek;
@@ -122,6 +126,7 @@ static int ASF_ReadObjectCommon( stream_t *s, asf_object_t *p_obj )
p_common->i_object_size = GetQWLE( p_peek + 16 );
p_common->i_object_pos = vlc_stream_Tell( s );
p_common->p_next = NULL;
+ p_common->i_level = i_level;
#ifdef ASF_DEBUG
msg_Dbg( s,
@@ -145,7 +150,7 @@ static int ASF_NextObject( stream_t *s, asf_object_t *p_obj, uint64_t i_boundary
if( p_obj == NULL )
{
- if( ASF_ReadObjectCommon( s, &obj ) )
+ if( ASF_ReadObjectCommon( s, &obj, 0 ) )
return VLC_EGENERIC;
p_obj = &obj;
@@ -1014,7 +1019,7 @@ static int ASF_ReadObject_extended_stream_properties( stream_t *s,
}
asf_object_t *p_sp = malloc( sizeof( asf_object_t ) );
- if( !p_sp || ASF_ReadObject( s, p_sp, NULL ) )
+ if( !p_sp || ASF_ReadObjectExpDepth( s, p_sp, NULL, p_obj->common.i_level + 1 ) )
{
free( p_sp );
}
@@ -1519,15 +1524,26 @@ static const struct ASF_Object_Function_entry * ASF_GetObject_Function( const gu
static int ASF_ReadObject( stream_t *s, asf_object_t *p_obj,
asf_object_t *p_father )
+{
+ unsigned i_depth = p_father ? p_father->common.i_level + 1: 0;
+
+ return ASF_ReadObjectExpDepth( s, p_obj, p_father, i_depth );
+}
+
+static int ASF_ReadObjectExpDepth( stream_t *s, asf_object_t *p_obj,
+ asf_object_t *p_father, unsigned i_depth )
{
int i_result = VLC_SUCCESS;
if( !p_obj )
return VLC_SUCCESS;
+ if( i_depth >= ASF_MAX_DEPTH )
+ return VLC_EGENERIC;
+
memset( p_obj, 0, sizeof( *p_obj ) );
- if( ASF_ReadObjectCommon( s, p_obj ) )
+ if( ASF_ReadObjectCommon( s, p_obj, i_depth ) )
{
msg_Warn( s, "cannot read one asf object" );
return VLC_EGENERIC;
@@ -1708,6 +1724,7 @@ asf_object_root_t *ASF_ReadObjectRoot( stream_t *s, int b_seekable )
memcpy( &p_root->i_object_id, &vlc_object_root_guid, sizeof( guid_t ) );
p_root->i_object_pos = vlc_stream_Tell( s );
p_root->i_object_size = 0;
+ p_root->i_level = 0;
p_root->p_first = NULL;
p_root->p_last = NULL;
p_root->p_next = NULL;
=====================================
modules/demux/asf/libasf.h
=====================================
@@ -33,6 +33,7 @@
#define ASF_OBJECT_COMMON \
int i_type; \
+ unsigned i_level; \
guid_t i_object_id; \
uint64_t i_object_size; \
uint64_t i_object_pos; \
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/6b24ce03d489348e7b4de163506da787bb1e1f85
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/6b24ce03d489348e7b4de163506da787bb1e1f85
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