From da95043002ed1db9f8531f104b297d18e63b82fc Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 23 Jun 2022 11:40:22 +0200 Subject: [PATCH] channelmix: guard against invalid channels --- spa/plugins/audioconvert/channelmix-ops.c | 4 ++++ spa/plugins/audioconvert/channelmix-ops.h | 2 -- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/spa/plugins/audioconvert/channelmix-ops.c b/spa/plugins/audioconvert/channelmix-ops.c index 76b1c701a..1ec172eb7 100644 --- a/spa/plugins/audioconvert/channelmix-ops.c +++ b/spa/plugins/audioconvert/channelmix-ops.c @@ -549,6 +549,10 @@ int channelmix_init(struct channelmix *mix) { const struct channelmix_info *info; + if (mix->src_chan > SPA_AUDIO_MAX_CHANNELS || + mix->dst_chan > SPA_AUDIO_MAX_CHANNELS) + return -EINVAL; + info = find_channelmix_info(mix->src_chan, mix->src_mask, mix->dst_chan, mix->dst_mask, mix->cpu_flags); if (info == NULL) diff --git a/spa/plugins/audioconvert/channelmix-ops.h b/spa/plugins/audioconvert/channelmix-ops.h index 08951267c..d43eafa4e 100644 --- a/spa/plugins/audioconvert/channelmix-ops.h +++ b/spa/plugins/audioconvert/channelmix-ops.h @@ -43,8 +43,6 @@ #define MASK_5_1 _M(FL)|_M(FR)|_M(FC)|_M(LFE)|_M(SL)|_M(SR)|_M(RL)|_M(RR) #define MASK_7_1 _M(FL)|_M(FR)|_M(FC)|_M(LFE)|_M(SL)|_M(SR)|_M(RL)|_M(RR) -#define BUFFER_SIZE 4096 - #define BUFFER_SIZE 4096 #define MAX_TAPS 255