Skip to content

Commit 338e17d

Browse files
alyptiktiwai
authored andcommitted
ALSA: ice1712: replace strcpy() with strlcpy()
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 <[email protected]> Suggested-by: Andy Shevchenko <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Signed-off-by: Takashi Iwai <[email protected]>
1 parent dd5f313 commit 338e17d

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

sound/pci/ice1712/juli.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include <linux/interrupt.h>
2828
#include <linux/init.h>
2929
#include <linux/slab.h>
30+
#include <linux/string.h>
3031
#include <sound/core.h>
3132
#include <sound/tlv.h>
3233

@@ -425,10 +426,9 @@ DECLARE_TLV_DB_SCALE(juli_master_db_scale, -6350, 50, 1);
425426
static struct snd_kcontrol *ctl_find(struct snd_card *card,
426427
const char *name)
427428
{
428-
struct snd_ctl_elem_id sid;
429-
memset(&sid, 0, sizeof(sid));
430-
/* FIXME: strcpy is bad. */
431-
strcpy(sid.name, name);
429+
struct snd_ctl_elem_id sid = {0};
430+
431+
strlcpy(sid.name, name, sizeof(sid.name));
432432
sid.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
433433
return snd_ctl_find_id(card, &sid);
434434
}

sound/pci/ice1712/quartet.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <linux/interrupt.h>
2727
#include <linux/init.h>
2828
#include <linux/slab.h>
29+
#include <linux/string.h>
2930
#include <sound/core.h>
3031
#include <sound/tlv.h>
3132
#include <sound/info.h>
@@ -785,10 +786,9 @@ DECLARE_TLV_DB_SCALE(qtet_master_db_scale, -6350, 50, 1);
785786
static struct snd_kcontrol *ctl_find(struct snd_card *card,
786787
const char *name)
787788
{
788-
struct snd_ctl_elem_id sid;
789-
memset(&sid, 0, sizeof(sid));
790-
/* FIXME: strcpy is bad. */
791-
strcpy(sid.name, name);
789+
struct snd_ctl_elem_id sid = {0};
790+
791+
strlcpy(sid.name, name, sizeof(sid.name));
792792
sid.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
793793
return snd_ctl_find_id(card, &sid);
794794
}

0 commit comments

Comments
 (0)