Skip to content

Commit 014c78d

Browse files
committed
mux: ipc4: validate channels_count before building mask
build_config() looped over host-supplied channels_count writing streams[].mask[] (size PLATFORM_MAX_CHANNELS), overflowing it. Reject counts above the max. Signed-off-by: Adrian Bonislawski <adrian.bonislawski@intel.com>
1 parent 3f7738d commit 014c78d

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

src/audio/mux/mux_ipc4.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,16 @@ static int build_config(struct processing_module *mod, struct mux_data *cfg)
3939
int mask = 1;
4040
int i;
4141

42+
/* channels_count is host-supplied; bound it to mask[] size */
43+
if (cfg->base_cfg.audio_fmt.channels_count > PLATFORM_MAX_CHANNELS ||
44+
cfg->reference_format.channels_count > PLATFORM_MAX_CHANNELS) {
45+
comp_err(dev, "invalid channel count: base %u reference %u (max %u)",
46+
cfg->base_cfg.audio_fmt.channels_count,
47+
cfg->reference_format.channels_count,
48+
PLATFORM_MAX_CHANNELS);
49+
return -EINVAL;
50+
}
51+
4252
cd->config.num_streams = MUX_MAX_STREAMS;
4353

4454
/* clear masks */

0 commit comments

Comments
 (0)