Re: [PATCH v3] ALSA: asihpi: detect truncated control names

Takashi Iwai
2026-03-28T13:14:11Z

On Sat, 28 Mar 2026 11:28:08 +0100,
Pengpeng Hou wrote:
>
> 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>

Applied to for-next branch now. Thanks.

Takashi