ALSA: control: Warn if too long string is passed to snd_ctl_enum_info()
authorTakashi Iwai <tiwai@suse.de>
Mon, 20 Oct 2014 16:07:21 +0000 (18:07 +0200)
committerTakashi Iwai <tiwai@suse.de>
Mon, 20 Oct 2014 16:25:27 +0000 (18:25 +0200)
This allows us to catch the bugs in drivers easily.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/core/control.c

index b9611344ff9e53ec351c420411ceb28f2ddb5b8a..f95df84437e1520410370e1f54eaf777e98ceb94 100644 (file)
@@ -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));
This page took 0.037745 seconds and 5 git commands to generate.