Skip to content

Commit f92766b

Browse files
Dan Carpentertiwai
authored andcommitted
ALSA: oss-mixer - use strlcpy() instead strcpy()
This is mostly a static checker fix more than anything else. We're copying from a 64 char buffer into a 44 char buffer. The 64 character buffer is str[] in snd_mixer_oss_build_test_all(). The call tree is: snd_mixer_oss_build_test_all() -> snd_mixer_oss_build_test() -> snd_mixer_oss_build_test(). We never actually do fill str[] buffer all the way to 64 characters. The longest string is: sprintf(str, "%s Playback Switch", ptr->name); ptr->name is a 32 character buffer so 32 plus 16 characters for " Playback Switch" still puts us over the 44 limit from "id.name". Most likely ptr->name never gets filled to the limit, but we can't really change the size of that buffer so lets just use strlcpy() here and be safe. Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent a0978e8 commit f92766b

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎sound/core/oss/mixer_oss.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ static struct snd_kcontrol *snd_mixer_oss_test_id(struct snd_mixer_oss *mixer, c
499499

500500
memset(&id, 0, sizeof(id));
501501
id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
502-
strcpy(id.name, name);
502+
strlcpy(id.name, name, sizeof(id.name));
503503
id.index = index;
504504
return snd_ctl_find_id(card, &id);
505505
}

0 commit comments

Comments
 (0)