提交 26e34e9e 编写于 作者: D Dan Carpenter 提交者: Takashi Iwai

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: NDan Carpenter <error27@gmail.com>
Signed-off-by: NTakashi Iwai <tiwai@suse.de>
上级 4437ecdc
......@@ -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;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册