[vlc-commits] [Git][videolan/vlc][master] 3 commits: fourcc: add sanity check on number of audio bits
Steve Lhomme (@robUx4)
gitlab at videolan.org
Wed May 13 10:08:37 UTC 2026
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
b899df2a by Steve Lhomme at 2026-05-13T09:56:47+00:00
fourcc: add sanity check on number of audio bits
Fixes #29836
- - - - -
cc19d191 by Steve Lhomme at 2026-05-13T09:56:47+00:00
fourcc: don't compute the number of bytes
We can use the number of bits and we don't need to check when the
fourcc is not one of the 4 raw VLC formats.
- - - - -
76d96d83 by Steve Lhomme at 2026-05-13T09:56:47+00:00
demux: caf: add sanity check on the number of channels
Ref. #29836
- - - - -
2 changed files:
- modules/demux/caf.c
- src/misc/fourcc.c
Changes:
=====================================
modules/demux/caf.c
=====================================
@@ -29,6 +29,7 @@
#endif
#include <math.h>
#include <limits.h>
+#include <inttypes.h>
#include <vlc_common.h>
#include <vlc_plugin.h>
#include <vlc_demux.h>
@@ -509,6 +510,11 @@ static int ReadDescChunk( demux_t *p_demux )
msg_Err( p_demux, "Sample rate must be non-zero" );
return VLC_EGENERIC;
}
+ if( i_channels_per_frame > AOUT_CHAN_MAX)
+ {
+ msg_Err( p_demux, "Too many channels %" PRIu32, i_channels_per_frame );
+ return VLC_EGENERIC;
+ }
p_sys->fmt.audio.i_channels = i_channels_per_frame;
p_sys->fmt.audio.i_bytes_per_frame = i_bytes_per_packet; /* "mBytesPerPacket" in Apple parlance */
p_sys->fmt.audio.i_frame_length = i_frames_per_packet; /* "mFramesPerPacket" in Apple parlance */
=====================================
src/misc/fourcc.c
=====================================
@@ -132,72 +132,51 @@ vlc_fourcc_t vlc_fourcc_GetCodecFromString( int i_cat, const char *psz_fourcc )
vlc_fourcc_t vlc_fourcc_GetCodecAudio( vlc_fourcc_t i_fourcc, int i_bits )
{
- const int i_bytes = ( i_bits + 7 ) / 8;
-
if( i_fourcc == VLC_FOURCC( 'a', 'f', 'l', 't' ) )
{
- switch( i_bytes )
- {
- case 4:
+ if ( i_bits >= 25 && i_bits <= 32 )
return VLC_CODEC_FL32;
- case 8:
+ if ( i_bits >= 57 && i_bits <= 64 )
return VLC_CODEC_FL64;
- default:
- return 0;
- }
+ return 0;
}
- else if( i_fourcc == VLC_FOURCC( 'a', 'r', 'a', 'w' ) )
+ if( i_fourcc == VLC_FOURCC( 'a', 'r', 'a', 'w' ) )
{
- switch( i_bytes )
- {
- case 1:
+ if ( i_bits >= 1 && i_bits <= 8 )
return VLC_CODEC_U8;
- case 2:
+ if ( i_bits >= 9 && i_bits <= 16 )
return VLC_CODEC_S16L;
- case 3:
+ if ( i_bits >= 17 && i_bits <= 24 )
return VLC_CODEC_S24L;
- case 4:
+ if ( i_bits >= 25 && i_bits <= 32 )
return VLC_CODEC_S32L;
- default:
- return 0;
- }
+ return 0;
}
- else if( i_fourcc == VLC_FOURCC( 't', 'w', 'o', 's' ) )
+ if( i_fourcc == VLC_FOURCC( 't', 'w', 'o', 's' ) )
{
- switch( i_bytes )
- {
- case 1:
+ if ( i_bits >= 1 && i_bits <= 8 )
return VLC_CODEC_S8;
- case 2:
+ if ( i_bits >= 9 && i_bits <= 16 )
return VLC_CODEC_S16B;
- case 3:
+ if ( i_bits >= 17 && i_bits <= 24 )
return VLC_CODEC_S24B;
- case 4:
+ if ( i_bits >= 25 && i_bits <= 32 )
return VLC_CODEC_S32B;
- default:
- return 0;
- }
+ return 0;
}
- else if( i_fourcc == VLC_FOURCC( 's', 'o', 'w', 't' ) )
+ if( i_fourcc == VLC_FOURCC( 's', 'o', 'w', 't' ) )
{
- switch( i_bytes )
- {
- case 1:
+ if ( i_bits >= 1 && i_bits <= 8 )
return VLC_CODEC_S8;
- case 2:
+ if ( i_bits >= 9 && i_bits <= 16 )
return VLC_CODEC_S16L;
- case 3:
+ if ( i_bits >= 17 && i_bits <= 24 )
return VLC_CODEC_S24L;
- case 4:
+ if ( i_bits >= 25 && i_bits <= 32 )
return VLC_CODEC_S32L;
- default:
- return 0;
- }
- }
- else
- {
- return vlc_fourcc_GetCodec( AUDIO_ES, i_fourcc );
+ return 0;
}
+ return vlc_fourcc_GetCodec( AUDIO_ES, i_fourcc );
}
const char *vlc_fourcc_GetDescription(int cat, vlc_fourcc_t fourcc)
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/5b2c3d633684ad1388399169e3986ab06a367f94...76d96d83dc65a203414a566649bc4320c876a0fe
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/5b2c3d633684ad1388399169e3986ab06a367f94...76d96d83dc65a203414a566649bc4320c876a0fe
You're receiving this email because of your account on code.videolan.org.
More information about the vlc-commits
mailing list