diff options
author | Dan Carpenter <error27@gmail.com> | 2010-09-16 14:13:47 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2010-09-16 16:50:51 -0400 |
commit | 26e34e9e15aa48e9375ea4e97bc4234ad995b7c8 (patch) | |
tree | 803a156b7a34a76bce5576c6c68fc0061e4372f9 /sound/usb | |
parent | 4437ecdc7190302ed02fb1467c116aff29c325b2 (diff) |
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 <error27@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/usb')
-rw-r--r-- | sound/usb/mixer.c | 5 |
1 files 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 | |||
1640 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | 1640 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; |
1641 | uinfo->count = 1; | 1641 | uinfo->count = 1; |
1642 | uinfo->value.enumerated.items = cval->max; | 1642 | uinfo->value.enumerated.items = cval->max; |
1643 | if ((int)uinfo->value.enumerated.item >= cval->max) | 1643 | if (uinfo->value.enumerated.item >= cval->max) |
1644 | uinfo->value.enumerated.item = cval->max - 1; | 1644 | uinfo->value.enumerated.item = cval->max - 1; |
1645 | strcpy(uinfo->value.enumerated.name, itemlist[uinfo->value.enumerated.item]); | 1645 | strlcpy(uinfo->value.enumerated.name, itemlist[uinfo->value.enumerated.item], |
1646 | sizeof(uinfo->value.enumerated.name)); | ||
1646 | return 0; | 1647 | return 0; |
1647 | } | 1648 | } |
1648 | 1649 | ||