[PATCH v2] ALSA: info: Use scnprintf() in snd_info_card_create()

From: Thorsten Blum

Date: Sat Nov 07 2026 - 09:13:54 EST


While the current code works correctly, replace the unbounded sprintf()
with scnprintf() to bound the formatted string to the str buffer.

Signed-off-by: Thorsten Blum <blum@xxxxxxxxxx>
---
Changes in v2:
- Switch to scnprintf() as suggested by Takashi
- v1: https://lore.kernel.org/r/20261107004338.323417-2-blum@xxxxxxxxxx/

sound/core/info.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/core/info.c b/sound/core/info.c
index 023b4736aa6d..2c2a80a7d0d2 100644
--- a/sound/core/info.c
+++ b/sound/core/info.c
@@ -484,7 +484,7 @@ int snd_info_card_create(struct snd_card *card)
if (snd_BUG_ON(!card))
return -ENXIO;

- sprintf(str, "card%i", card->number);
+ scnprintf(str, sizeof(str), "card%i", card->number);
entry = create_subdir(card->module, str);
if (!entry)
return -ENOMEM;