[vlc-commits] [Git][videolan/vlc][3.0.x] 3 commits: asf: use the table size to check if the number of streams can fit

Steve Lhomme (@robUx4) gitlab at videolan.org
Thu Jul 31 15:55:37 UTC 2025



Steve Lhomme pushed to branch 3.0.x at VideoLAN / VLC


Commits:
60e3b680 by Steve Lhomme at 2025-07-31T15:39:01+00:00
asf: use the table size to check if the number of streams can fit

This is more logical. The #if check should also use that, but we can't use
sizeof() here.

(cherry picked from commit a7c77cf44777eaabfbeea756eaacb8ceea8bda36)

- - - - -
4f60d1ac by Steve Lhomme at 2025-07-31T15:39:01+00:00
modules: allocate with the table type size

So there can be no mismatch.

(cherry picked from commit 8b2d42c400cbdc4cea05c0149864530e3ba728f4)

- - - - -
2f3633f1 by Steve Lhomme at 2025-07-31T15:39:01+00:00
demux: asf: remove hardcoded overflow checks

vlc_alloc does check the multiplying is possible.

(cherry picked from commit c0a72e5cda0f8c71f096cfe9008f630ab8ad9607)

- - - - -


4 changed files:

- modules/demux/asf/asf.c
- modules/demux/asf/libasf.c
- modules/demux/mp4/libmp4.c
- modules/lua/extension.c


Changes:

=====================================
modules/demux/asf/asf.c
=====================================
@@ -731,11 +731,7 @@ static void ASF_fillup_es_priorities_ex( demux_sys_t *p_sys, void *p_hdr,
             ASF_FindObject( p_hdr, &asf_object_advanced_mutual_exclusion, 0 );
     if (! p_mutex ) return;
 
-#if ( UINT_MAX > SIZE_MAX / 2 )
-    if ( p_sys->i_track > (size_t)SIZE_MAX / sizeof(uint16_t) )
-        return;
-#endif
-    p_prios->pi_stream_numbers = vlc_alloc( p_sys->i_track, sizeof(uint16_t) );
+    p_prios->pi_stream_numbers = vlc_alloc( p_sys->i_track, sizeof(*p_prios->pi_stream_numbers) );
     if ( !p_prios->pi_stream_numbers ) return;
 
     if ( p_mutex->i_stream_number_count )
@@ -758,11 +754,7 @@ static void ASF_fillup_es_bitrate_priorities_ex( demux_sys_t *p_sys, void *p_hdr
             ASF_FindObject( p_hdr, &asf_object_bitrate_mutual_exclusion_guid, 0 );
     if (! p_bitrate_mutex ) return;
 
-#if ( UINT_MAX > SIZE_MAX / 2 )
-    if ( p_sys->i_track > (size_t)SIZE_MAX / sizeof(uint16_t) )
-        return;
-#endif
-    p_prios->pi_stream_numbers = vlc_alloc( p_sys->i_track, sizeof( uint16_t ) );
+    p_prios->pi_stream_numbers = vlc_alloc( p_sys->i_track, sizeof(*p_prios->pi_stream_numbers) );
     if ( !p_prios->pi_stream_numbers ) return;
 
     if ( p_bitrate_mutex->i_stream_number_count )
@@ -1440,4 +1432,3 @@ static void DemuxEnd( demux_t *p_demux )
         p_sys->track[i] = 0;
     }
 }
-


=====================================
modules/demux/asf/libasf.c
=====================================
@@ -957,9 +957,9 @@ static int ASF_ReadObject_extended_stream_properties( stream_t *s,
     p_data += 64;
 
     p_esp->pi_stream_name_language = calloc( p_esp->i_stream_name_count,
-                                             sizeof(uint16_t) );
+                                             sizeof(*p_esp->pi_stream_name_language) );
     p_esp->ppsz_stream_name = calloc( p_esp->i_stream_name_count,
-                                      sizeof(char*) );
+                                      sizeof(*p_esp->ppsz_stream_name) );
     if( !p_esp->pi_stream_name_language ||
         !p_esp->ppsz_stream_name )
     {
@@ -1081,7 +1081,7 @@ static int ASF_ReadObject_advanced_mutual_exclusion( stream_t *s,
     ASF_SKIP( 16 );
 
     p_ae->i_stream_number_count = ASF_READ2();
-    p_ae->pi_stream_number = calloc( p_ae->i_stream_number_count, sizeof(uint16_t) );
+    p_ae->pi_stream_number = calloc( p_ae->i_stream_number_count, sizeof(*p_ae->pi_stream_number) );
     if ( !p_ae->pi_stream_number )
     {
         p_ae->i_stream_number_count = 0;
@@ -1134,9 +1134,10 @@ static int ASF_ReadObject_stream_prioritization( stream_t *s,
 
     p_sp->i_priority_count = ASF_READ2();
 
-    p_sp->pi_priority_flag = calloc( p_sp->i_priority_count, sizeof(uint16_t) );
-    p_sp->pi_priority_stream_number =
-                             calloc( p_sp->i_priority_count, sizeof(uint16_t) );
+    p_sp->pi_priority_flag = calloc( p_sp->i_priority_count,
+                                     sizeof(*p_sp->pi_priority_flag) );
+    p_sp->pi_priority_stream_number = calloc( p_sp->i_priority_count,
+                                              sizeof(*p_sp->pi_priority_stream_number) );
 
     if( !p_sp->pi_priority_flag || !p_sp->pi_priority_stream_number )
     {
@@ -1195,7 +1196,7 @@ static int ASF_ReadObject_bitrate_mutual_exclusion( stream_t *s, asf_object_t *p
     ASF_SKIP( 16 );
 
     p_ex->i_stream_number_count = ASF_READ2();
-    p_ex->pi_stream_numbers = calloc( p_ex->i_stream_number_count, sizeof(uint16_t) );
+    p_ex->pi_stream_numbers = calloc( p_ex->i_stream_number_count, sizeof(*p_ex->pi_stream_numbers) );
     if ( ! p_ex->pi_stream_numbers )
     {
         p_ex->i_stream_number_count = 0;


=====================================
modules/demux/mp4/libmp4.c
=====================================
@@ -3288,7 +3288,7 @@ static int MP4_ReadBox_stdp( stream_t *p_stream, MP4_Box_t *p_box )
     MP4_GETVERSIONFLAGS( p_box->data.p_stdp );
 
     p_box->data.p_stdp->i_priority =
-        calloc( i_read / 2, sizeof(uint16_t) );
+        calloc( i_read / 2, sizeof(*p_box->data.p_stdp->i_priority) );
 
     if( unlikely( !p_box->data.p_stdp->i_priority ) )
         MP4_READBOX_EXIT( 0 );


=====================================
modules/lua/extension.c
=====================================
@@ -761,8 +761,8 @@ static int GetMenuEntries( extensions_manager_t *p_mgr, extension_t *p_ext,
         {
             /* Get table size */
             size_t i_size = lua_objlen( L, -1 );
-            *pppsz_titles = ( char** ) calloc( i_size+1, sizeof( char* ) );
-            *ppi_ids = ( uint16_t* ) calloc( i_size+1, sizeof( uint16_t ) );
+            *pppsz_titles = ( char** ) calloc( i_size+1, sizeof( **pppsz_titles ) );
+            *ppi_ids = ( uint16_t* ) calloc( i_size+1, sizeof( **ppi_ids ) );
 
             /* Walk table */
             size_t i_idx = 0;



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/64af7294faab7a8affe33d6eb02bb4529281394c...2f3633f15953533658eb8d5ed26924bf0fe3b877

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/64af7294faab7a8affe33d6eb02bb4529281394c...2f3633f15953533658eb8d5ed26924bf0fe3b877
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list