Skip to contentSkip to conversation

ALSA: info: Use scnprintf() in snd_info_card_create()

PATCH Applied Thorsten Blum 2 participants 2 messages Nov 7 – Nov 8 Sound

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 ALSA: info: Use scnprintf() in snd_info_card_create()

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

---
Changes in v2:
- Switch to scnprintf() as suggested by Takashi
- v1: https://lore.kernel.org/r/[email protected]/

 sound/core/info.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/core/info.c +1 -1
index 023b4736aa6d..2c2a80a7d0d2 100644
@@ -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;
Applied
#1 lore raw
Quoted 5 lines · Thorsten Blum

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

Applied to for-next branch now. Thanks.

Takashi