Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH -next] ALSA: gus: Replace unsafe strcpy() with strscpy()
@ 2021-05-14  7:05 YueHaibing
  2021-05-14  7:47 ` Takashi Iwai
  0 siblings, 1 reply; 2+ messages in thread
From: YueHaibing @ 2021-05-14  7:05 UTC (permalink / raw)
  To: perex, tiwai, gregkh; +Cc: alsa-devel, YueHaibing, linux-kernel

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.

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
---
 sound/isa/gus/gus_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/isa/gus/gus_main.c b/sound/isa/gus/gus_main.c
index b7518122a10d..7524ce5785de 100644
--- a/sound/isa/gus/gus_main.c
+++ b/sound/isa/gus/gus_main.c
@@ -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;
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-05-14  7:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-05-14  7:05 [PATCH -next] ALSA: gus: Replace unsafe strcpy() with strscpy() YueHaibing
2021-05-14  7:47 ` Takashi Iwai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox