usb: gadget: u_audio: fix the risk of strcpy out of bounds

We use strlcpy instead of strcpy to ensure that array won't out
of bounds.

Fixes: a322b6c50d (FROMLIST: usb: gadget: f_uac*: Support multiple sampling rates)
Signed-off-by: Ren Jianing <jianing.ren@rock-chips.com>
Change-Id: Iebda94fea94dc929320273c16de996ff0d2d6397
This commit is contained in:
Ren Jianing
2020-09-25 10:02:31 +08:00
committed by Tao Huang
parent 83aa893b04
commit 6b55083a5e

View File

@@ -416,7 +416,7 @@ static struct snd_kcontrol *u_audio_get_ctl(struct g_audio *audio_dev,
memset(&elem_id, 0, sizeof(elem_id));
elem_id.iface = SNDRV_CTL_ELEM_IFACE_PCM;
strcpy(elem_id.name, name);
strlcpy(elem_id.name, name, sizeof(elem_id.name));
return snd_ctl_find_id(audio_dev->uac->card, &elem_id);
}