[vlc-commits] [Git][videolan/vlc][master] 3 commits: demux: voc: remove unneeded mulitplying by 1

Steve Lhomme (@robUx4) gitlab at videolan.org
Sun Aug 24 15:43:28 UTC 2025



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
aa19e5e6 by Steve Lhomme at 2025-08-24T15:27:47+00:00
demux: voc: remove unneeded mulitplying by 1

new_fmt.audio.i_channels is always 1 in this part of the code.

- - - - -
34057a6d by Steve Lhomme at 2025-08-24T15:27:47+00:00
demux: voc: check the number of channels read is usable

- - - - -
dd8256bf by Steve Lhomme at 2025-08-24T15:27:47+00:00
demux: voc: limit the maximum sampling rate to 768000

Ref. #28978

- - - - -


1 changed file:

- modules/demux/voc.c


Changes:

=====================================
modules/demux/voc.c
=====================================
@@ -229,15 +229,13 @@ static int ReadBlockHeader( demux_t *p_demux )
             }
 
             new_fmt.audio.i_channels = 1;
-            new_fmt.audio.i_bytes_per_frame *= new_fmt.audio.i_channels;
             new_fmt.audio.i_blockalign = new_fmt.audio.i_bytes_per_frame;
 
             new_fmt.audio.i_frame_length = new_fmt.audio.i_bytes_per_frame * 8
                                          / new_fmt.audio.i_bitspersample;
 
             new_fmt.audio.i_rate = fix_voc_sr( 1000000L / (256L - buf[0]) );
-            new_fmt.i_bitrate = new_fmt.audio.i_rate * new_fmt.audio.i_bitspersample
-                              * new_fmt.audio.i_channels;
+            new_fmt.i_bitrate = new_fmt.audio.i_rate * new_fmt.audio.i_bitspersample;
 
             break;
 
@@ -308,6 +306,7 @@ static int ReadBlockHeader( demux_t *p_demux )
             }
 
             new_fmt.i_codec = VLC_CODEC_U8;
+            static_assert( INPUT_CHAN_MAX > 32, "INPUT_CHAN_MAX too small" );
             if (buf[3] >= 32)
                 goto corrupt;
             new_fmt.audio.i_channels = buf[3] + 1; /* can't be nul */
@@ -351,7 +350,7 @@ static int ReadBlockHeader( demux_t *p_demux )
                 goto corrupt;
 
             new_fmt.audio.i_rate = GetDWLE( buf );
-            if( !new_fmt.audio.i_rate )
+            if( new_fmt.audio.i_rate == 0 || new_fmt.audio.i_rate > 768000 )
                 goto corrupt;
             new_fmt.audio.i_bitspersample = buf[4];
             new_fmt.audio.i_channels = buf[5];
@@ -404,6 +403,11 @@ static int ReadBlockHeader( demux_t *p_demux )
                 msg_Err( p_demux, "0 channels detected" );
                 return VLC_EGENERIC;
             }
+            if ( new_fmt.audio.i_channels > INPUT_CHAN_MAX )
+            {
+                msg_Err( p_demux, "too many channels detected %" PRIu8, new_fmt.audio.i_channels );
+                return VLC_EGENERIC;
+            }
 
             new_fmt.audio.i_bytes_per_frame = new_fmt.audio.i_channels
                 * (new_fmt.audio.i_bitspersample / 8);



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/63c36ef5af18366f38c7229d653a9e29eead7f06...dd8256bfdb821871b7e25e32d5fb325cb679c5e6

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/63c36ef5af18366f38c7229d653a9e29eead7f06...dd8256bfdb821871b7e25e32d5fb325cb679c5e6
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