From 26e34e9e15aa48e9375ea4e97bc4234ad995b7c8 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Thu, 16 Sep 2010 20:13:47 +0200 Subject: [PATCH] ALSA: usb/mixer: remove bogus cast "uinfo->value.enumerated.item" is an unsigned int. If it's negative when we do the comparison: if ((int)uinfo->value.enumerated.item >= cval->max) then we would read past the end of the array on the next line. I also changed the strcpy() to strlcpy() out of paranoia. Signed-off-by: Dan Carpenter Signed-off-by: Takashi Iwai --- sound/usb/mixer.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c index 5f12e294b0f8..f2d74d654b3c 100644 --- a/sound/usb/mixer.c +++ b/sound/usb/mixer.c @@ -1640,9 +1640,10 @@ static int mixer_ctl_selector_info(struct snd_kcontrol *kcontrol, struct snd_ctl uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; uinfo->count = 1; uinfo->value.enumerated.items = cval->max; - if ((int)uinfo->value.enumerated.item >= cval->max) + if (uinfo->value.enumerated.item >= cval->max) uinfo->value.enumerated.item = cval->max - 1; - strcpy(uinfo->value.enumerated.name, itemlist[uinfo->value.enumerated.item]); + strlcpy(uinfo->value.enumerated.name, itemlist[uinfo->value.enumerated.item], + sizeof(uinfo->value.enumerated.name)); return 0; } -- 2.20.1