[alsa-devel] [PATCH 2/2] ALSA: snd-usb: use strncpy() in mixer_quirks.c

Daniel Mack daniel at zonque.org
Sun Oct 19 09:11:26 CEST 2014


Out of principles, use strncpy() in favor of strcpy().
That is, however, an insignificant detail here.

Signed-off-by: Daniel Mack <daniel at zonque.org>
---
 sound/usb/mixer_quirks.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/sound/usb/mixer_quirks.c b/sound/usb/mixer_quirks.c
index f119a41..f406305 100644
--- a/sound/usb/mixer_quirks.c
+++ b/sound/usb/mixer_quirks.c
@@ -446,8 +446,9 @@ static int snd_emu0204_ch_switch_info(struct snd_kcontrol *kcontrol,
 	uinfo->value.enumerated.items = 2;
 	if (uinfo->value.enumerated.item > 1)
 		uinfo->value.enumerated.item = 1;
-	strcpy(uinfo->value.enumerated.name,
-		texts[uinfo->value.enumerated.item]);
+	strncpy(uinfo->value.enumerated.name,
+		texts[uinfo->value.enumerated.item],
+		sizeof(uinfo->value.enumerated.name) - 1);
 
 	return 0;
 }
-- 
2.1.0



More information about the Alsa-devel mailing list