From: Dan Carpenter <error27@gmail.com>
To: kernel-janitors@vger.kernel.org
Subject: [patch] ALSA: usb/mixer: remove bogus cast
Date: Thu, 16 Sep 2010 18:13:47 +0000 [thread overview]
Message-ID: <20100916181347.GC7867@bicker> (raw)
"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>
diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c
index 3ed3901..93c95c5 100644
--- a/sound/usb/mixer.c
+++ b/sound/usb/mixer.c
@@ -1642,9 +1642,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;
}
next reply other threads:[~2010-09-16 18:13 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-16 18:13 Dan Carpenter [this message]
2010-09-16 21:11 ` [patch] ALSA: usb/mixer: remove bogus cast Takashi Iwai
2010-09-16 21:11 ` Takashi Iwai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100916181347.GC7867@bicker \
--to=error27@gmail.com \
--cc=kernel-janitors@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.