]> git.alsa-project.org Git - alsa-lib.git/commit
topology: ctl: fix potential endless loop in tplg_decode_control_enum
authorJaroslav Kysela <perex@perex.cz>
Mon, 30 Nov 2026 13:40:24 +0000 (14:40 +0100)
committerJaroslav Kysela <perex@perex.cz>
Mon, 30 Nov 2026 13:41:33 +0000 (14:41 +0100)
commitbfb27a70a8e1a105779b40625f11d05bb1727c6b
treec9d3530897f2ded974e3e61a424bf0d6b2c1a758
parent36c34b261b80be2d97bc885fe8ad3894abd22337
topology: ctl: fix potential endless loop in tplg_decode_control_enum

The enum decode loop computed size2 = ec->size + ec->priv.size and only
rejected it for being too large (size2 > size). When both ec->size and
ec->priv.size are zero, size2 is zero, which passes that check, and the
loop advances bin/size/pos by zero and loops forever.

Unlike tplg_decode_control_mixer1() and tplg_decode_control_bytes1(),
tplg_decode_control_enum1() never received the computed size and had no
lower-bound size validation. Make it consistent with the mixer/bytes
helpers: pass (bin, size) and reject size < sizeof(*ec). Since the
structure size is non-zero, any accepted element guarantees forward
progress, which eliminates the endless loop.

Closes: https://github.com/alsa-project/alsa-lib/issues/535
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
src/topology/ctl.c
src/topology/dapm.c
src/topology/tplg_local.h