[alsa-devel] [PATCH 02/43] ALSA: control: Warn if too long string is passed to snd_ctl_enum_info()
Takashi Iwai
tiwai at suse.de
Tue Oct 21 12:10:38 CEST 2014
This allows us to catch the bugs in drivers easily.
Signed-off-by: Takashi Iwai <tiwai at suse.de>
---
sound/core/control.c | 3 +++
1 file changed, 3 insertions(+)
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,
info->value.enumerated.items = items;
if (info->value.enumerated.item >= items)
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,
names[info->value.enumerated.item],
sizeof(info->value.enumerated.name));
--
2.1.2
More information about the Alsa-devel
mailing list