diff options
author | Takashi Iwai <tiwai@suse.de> | 2014-10-20 12:07:21 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2014-10-20 12:25:27 -0400 |
commit | df803e1389716bcdf11932fff47d7f1fc198bc8a (patch) | |
tree | 9f5942d72a648d3686aa0967f6795da07485853c /sound/core | |
parent | be93709cb13a1947fec3493267d04cd87baf497e (diff) |
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>
Diffstat (limited to 'sound/core')
-rw-r--r-- | sound/core/control.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/sound/core/control.c b/sound/core/control.c index b9611344ff9e..f95df84437e1 100644 --- a/sound/core/control.c +++ b/sound/core/control.c | |||
@@ -1747,6 +1747,9 @@ int snd_ctl_enum_info(struct snd_ctl_elem_info *info, unsigned int channels, | |||
1747 | info->value.enumerated.items = items; | 1747 | info->value.enumerated.items = items; |
1748 | if (info->value.enumerated.item >= items) | 1748 | if (info->value.enumerated.item >= items) |
1749 | info->value.enumerated.item = items - 1; | 1749 | info->value.enumerated.item = items - 1; |
1750 | WARN(strlen(names[info->value.enumerated.item]) >= sizeof(info->value.enumerated.name), | ||
1751 | "ALSA: too long item name '%s'\n", | ||
1752 | names[info->value.enumerated.item]); | ||
1750 | strlcpy(info->value.enumerated.name, | 1753 | strlcpy(info->value.enumerated.name, |
1751 | names[info->value.enumerated.item], | 1754 | names[info->value.enumerated.item], |
1752 | sizeof(info->value.enumerated.name)); | 1755 | sizeof(info->value.enumerated.name)); |