]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
ALSA: ice1712: replace strcpy() with strlcpy()
authorJoey Pabalinas <joeypabalinas@gmail.com>
Thu, 1 Mar 2018 14:17:07 +0000 (04:17 -1000)
committerTakashi Iwai <tiwai@suse.de>
Thu, 1 Mar 2018 15:13:13 +0000 (16:13 +0100)
Replace unsafe usages of strcpy() to copy the name
argument into the sid.name buffer with strlcpy()
to guard against possible buffer overflows.

Signed-off-by: Joey Pabalinas <joeypabalinas@gmail.com>
Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/pci/ice1712/juli.c
sound/pci/ice1712/quartet.c

index 0dbaccf61f332706081a748d62a3a87b997e35a3..21806bab4757241a9e387210935f7ba1197586a8 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/interrupt.h>
 #include <linux/init.h>
 #include <linux/slab.h>
+#include <linux/string.h>
 #include <sound/core.h>
 #include <sound/tlv.h>
 
@@ -425,10 +426,9 @@ DECLARE_TLV_DB_SCALE(juli_master_db_scale, -6350, 50, 1);
 static struct snd_kcontrol *ctl_find(struct snd_card *card,
                                     const char *name)
 {
-       struct snd_ctl_elem_id sid;
-       memset(&sid, 0, sizeof(sid));
-       /* FIXME: strcpy is bad. */
-       strcpy(sid.name, name);
+       struct snd_ctl_elem_id sid = {0};
+
+       strlcpy(sid.name, name, sizeof(sid.name));
        sid.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
        return snd_ctl_find_id(card, &sid);
 }
index d145b5eb7ff86d978debce8eb93aaa0d4dfbc50a..5bc836241c977feb517e7c8d1e049a62271a5470 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/interrupt.h>
 #include <linux/init.h>
 #include <linux/slab.h>
+#include <linux/string.h>
 #include <sound/core.h>
 #include <sound/tlv.h>
 #include <sound/info.h>
@@ -785,10 +786,9 @@ DECLARE_TLV_DB_SCALE(qtet_master_db_scale, -6350, 50, 1);
 static struct snd_kcontrol *ctl_find(struct snd_card *card,
                                     const char *name)
 {
-       struct snd_ctl_elem_id sid;
-       memset(&sid, 0, sizeof(sid));
-       /* FIXME: strcpy is bad. */
-       strcpy(sid.name, name);
+       struct snd_ctl_elem_id sid = {0};
+
+       strlcpy(sid.name, name, sizeof(sid.name));
        sid.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
        return snd_ctl_find_id(card, &sid);
 }