]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
ALSA: asihpi: detect truncated control names
authorPengpeng Hou <pengpeng@iscas.ac.cn>
Sat, 28 Mar 2026 10:28:08 +0000 (18:28 +0800)
committerTakashi Iwai <tiwai@suse.de>
Sat, 28 Mar 2026 13:13:04 +0000 (14:13 +0100)
commit18d4969e22cc3ff738257e1d7738aafc65a6d2d2
tree832d730b95d4ad1050a97d29dc5df13dbffca9c4
parent796e119e9b14763be905ad0d023c71a14bc2e931
ALSA: asihpi: detect truncated control names

asihpi_ctl_init() builds mixer control names in the fixed 44-byte
hpi_ctl->name buffer with sprintf().

This is not only a defensive cleanup. The current in-tree name tables and
format strings can already exceed 44 bytes. For example,

  "Bitstream 0 Internal 0 Monitor Playback Volume"

is 46 characters before the trailing NUL, so the current sprintf() call
writes past the end of hpi_ctl->name.

The generated control name is used as the ALSA control element key, so
blindly truncating it is not sufficient. Switch the formatting to
snprintf() and emit an error if truncation happens, showing the
truncated name while still keeping the write bounded to hpi_ctl->name.

Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>
Link: https://patch.msgid.link/20260328102808.33969-1-pengpeng@iscas.ac.cn
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/pci/asihpi/asihpi.c