forked from Minki/linux
ALSA: control: Warn if too long string is passed to snd_ctl_enum_info()
This allows us to catch the bugs in drivers easily. Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
be93709cb1
commit
df803e1389
@ -1747,6 +1747,9 @@ int snd_ctl_enum_info(struct snd_ctl_elem_info *info, unsigned int channels,
|
|||||||
info->value.enumerated.items = items;
|
info->value.enumerated.items = items;
|
||||||
if (info->value.enumerated.item >= items)
|
if (info->value.enumerated.item >= items)
|
||||||
info->value.enumerated.item = items - 1;
|
info->value.enumerated.item = items - 1;
|
||||||
|
WARN(strlen(names[info->value.enumerated.item]) >= sizeof(info->value.enumerated.name),
|
||||||
|
"ALSA: too long item name '%s'\n",
|
||||||
|
names[info->value.enumerated.item]);
|
||||||
strlcpy(info->value.enumerated.name,
|
strlcpy(info->value.enumerated.name,
|
||||||
names[info->value.enumerated.item],
|
names[info->value.enumerated.item],
|
||||||
sizeof(info->value.enumerated.name));
|
sizeof(info->value.enumerated.name));
|
||||||
|
Loading…
Reference in New Issue
Block a user