]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ALSA: ac97: Use safer strscpy() instead of strcpy()
authorTakashi Iwai <tiwai@suse.de>
Thu, 10 Jul 2025 10:06:23 +0000 (12:06 +0200)
committerTakashi Iwai <tiwai@suse.de>
Fri, 11 Jul 2025 07:53:16 +0000 (09:53 +0200)
Use a safer function strscpy() instead of strcpy() for copying to
arrays.

Only idiomatic code replacement, and no functional changes.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://patch.msgid.link/20250710100727.22653-42-tiwai@suse.de
sound/pci/ac97/ac97_codec.c
sound/pci/ac97/ac97_patch.c

index 88ac37739b7653f69af430dd0163f5ab4ddf0d0c..588c094080beae64324b1f7ddf6ecc060a82e630 100644 (file)
@@ -2303,7 +2303,7 @@ int snd_ac97_mixer(struct snd_ac97_bus *bus, struct snd_ac97_template *template,
        if (ac97_is_audio(ac97)) {
                char comp[16];
                if (card->mixername[0] == '\0') {
-                       strcpy(card->mixername, name);
+                       strscpy(card->mixername, name);
                } else {
                        if (strlen(card->mixername) + 1 + strlen(name) + 1 <= sizeof(card->mixername)) {
                                strcat(card->mixername, ",");
@@ -2324,7 +2324,7 @@ int snd_ac97_mixer(struct snd_ac97_bus *bus, struct snd_ac97_template *template,
        if (ac97_is_modem(ac97)) {
                char comp[16];
                if (card->mixername[0] == '\0') {
-                       strcpy(card->mixername, name);
+                       strscpy(card->mixername, name);
                } else {
                        if (strlen(card->mixername) + 1 + strlen(name) + 1 <= sizeof(card->mixername)) {
                                strcat(card->mixername, ",");
index cd83aa864ea3e6e966140803a19818d663c49d72..3002be9d88f306a77f494fa518c3aff5fc2e12f2 100644 (file)
@@ -298,7 +298,7 @@ static int patch_yamaha_ymf7x3_3d(struct snd_ac97 *ac97)
        err = snd_ctl_add(ac97->bus->card, kctl);
        if (err < 0)
                return err;
-       strcpy(kctl->id.name, "3D Control - Wide");
+       strscpy(kctl->id.name, "3D Control - Wide");
        kctl->private_value = AC97_SINGLE_VALUE(AC97_3D_CONTROL, 9, 7, 0);
        snd_ac97_write_cache(ac97, AC97_3D_CONTROL, 0x0000);
        err = snd_ctl_add(ac97->bus->card,
@@ -891,7 +891,7 @@ static int patch_sigmatel_stac9700_3d(struct snd_ac97 * ac97)
        err = snd_ctl_add(ac97->bus->card, kctl = snd_ac97_cnew(&snd_ac97_controls_3d[0], ac97));
        if (err < 0)
                return err;
-       strcpy(kctl->id.name, "3D Control Sigmatel - Depth");
+       strscpy(kctl->id.name, "3D Control Sigmatel - Depth");
        kctl->private_value = AC97_SINGLE_VALUE(AC97_3D_CONTROL, 2, 3, 0);
        snd_ac97_write_cache(ac97, AC97_3D_CONTROL, 0x0000);
        return 0;
@@ -906,13 +906,13 @@ static int patch_sigmatel_stac9708_3d(struct snd_ac97 * ac97)
        err = snd_ctl_add(ac97->bus->card, kctl);
        if (err < 0)
                return err;
-       strcpy(kctl->id.name, "3D Control Sigmatel - Depth");
+       strscpy(kctl->id.name, "3D Control Sigmatel - Depth");
        kctl->private_value = AC97_SINGLE_VALUE(AC97_3D_CONTROL, 0, 3, 0);
        kctl = snd_ac97_cnew(&snd_ac97_controls_3d[0], ac97);
        err = snd_ctl_add(ac97->bus->card, kctl);
        if (err < 0)
                return err;
-       strcpy(kctl->id.name, "3D Control Sigmatel - Rear Depth");
+       strscpy(kctl->id.name, "3D Control Sigmatel - Rear Depth");
        kctl->private_value = AC97_SINGLE_VALUE(AC97_3D_CONTROL, 2, 3, 0);
        snd_ac97_write_cache(ac97, AC97_3D_CONTROL, 0x0000);
        return 0;