From ba11f91599ad7bccf8c18c1b6c0f2ab1deb34824 Mon Sep 17 00:00:00 2001 From: WeebDataHoarder <57538841+WeebDataHoarder@users.noreply.github.com> Date: Sat, 23 Apr 2022 16:52:21 +0200 Subject: [PATCH] Added decoder sanity checks for bitDepth, channels --- codec/ALACDecoder.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/codec/ALACDecoder.cpp b/codec/ALACDecoder.cpp index 7804728..c8f0d17 100644 --- a/codec/ALACDecoder.cpp +++ b/codec/ALACDecoder.cpp @@ -128,10 +128,13 @@ int32_t ALACDecoder::Init( void * inMagicCookie, uint32_t inMagicCookieSize ) theConfig.sampleRate = Swap32BtoN(((ALACSpecificConfig *)theActualCookie)->sampleRate); mConfig = theConfig; - + + //sanity checks RequireAction( mConfig.compatibleVersion <= kALACVersion, return kALAC_ParamError; ); + RequireAction( mConfig.bitDepth == 16 || mConfig.bitDepth == 20 || mConfig.bitDepth == 24 || mConfig.bitDepth == 32, return kALAC_ParamError; ); RequireAction( mConfig.frameLength > 0 && mConfig.frameLength <= 16384, return kALAC_ParamError; ); RequireAction( mConfig.sampleRate > 0 && mConfig.sampleRate <= 384000, return kALAC_ParamError; ); + RequireAction( mConfig.numChannels > 0 && mConfig.numChannels < kALACMaxChannels, return kALAC_ParamError; ); // allocate mix buffers mMixBufferU = (int32_t *) calloc( mConfig.frameLength * sizeof(int32_t), 1 );