Skip to contentSkip to conversation

ALSA: gus: Replace unsafe strcpy() with strscpy()

PATCH Applied YueHaibing 2 participants 2 messages May 14, 2021 Sound

lore
Share & tools
lore

YueHaibing

author
#0 lore raw

PATCH 1/1 ALSA: gus: Replace unsafe strcpy() with strscpy()

Fix smatch warning:
sound/isa/gus/gus_main.c:396 snd_gus_check_version() error:
strcpy() 'card->longname' too large for 'card->shortname' (80 vs 32)

Even if this is not a real bug since the longest length of card->longname now is 31, replace strcpy() with strscpy() in order to avoid possible future mistake.

---
 sound/isa/gus/gus_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/isa/gus/gus_main.c +1 -1
index b7518122a10d..7524ce5785de 100644
@@ -384,7 +384,7 @@ static int snd_gus_check_version(struct snd_gus_card * gus)
 			}
 		}
 	}
-	strcpy(card->shortname, card->longname);
+	strscpy(card->shortname, card->longname, sizeof(card->shortname));
 	gus->uart_enable = 1;	/* standard GUSes doesn't have midi uart trouble */
 	snd_gus_init_control(gus);
 	return 0;
Signature · 1 line
2.17.1
Applied
#1 lore raw
Quoted 10 lines · YueHaibing

Fix smatch warning:
sound/isa/gus/gus_main.c:396 snd_gus_check_version() error:
strcpy() 'card->longname' too large for 'card->shortname' (80 vs 32)

Even if this is not a real bug since the longest length of card->longname now is 31, replace strcpy() with strscpy() in order to avoid possible future mistake.

Applied, thanks.

Takashi