]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ALSA: gus: Use safer strscpy() instead of strcpy()
authorTakashi Iwai <tiwai@suse.de>
Thu, 10 Jul 2025 10:06:13 +0000 (12:06 +0200)
committerTakashi Iwai <tiwai@suse.de>
Fri, 11 Jul 2025 07:53:15 +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-32-tiwai@suse.de
sound/isa/gus/gus_main.c
sound/isa/gus/gus_mixer.c
sound/isa/gus/gus_pcm.c
sound/isa/gus/gus_timer.c
sound/isa/gus/gus_uart.c
sound/isa/gus/gusextreme.c
sound/isa/gus/gusmax.c
sound/isa/gus/interwave.c

index 7166869e423d90fa6686b3eb0c6b8a2a07beb61d..873ef4046cd699daf07cb486f02e7aea881f1f0c 100644 (file)
@@ -348,8 +348,8 @@ static int snd_gus_check_version(struct snd_gus_card * gus)
        rev = inb(GUSP(gus, BOARDVERSION));
        spin_unlock_irqrestore(&gus->reg_lock, flags);
        dev_dbg(card->dev, "GF1 [0x%lx] init - val = 0x%x, rev = 0x%x\n", gus->gf1.port, val, rev);
-       strcpy(card->driver, "GUS");
-       strcpy(card->longname, "Gravis UltraSound Classic (2.4)");
+       strscpy(card->driver, "GUS");
+       strscpy(card->longname, "Gravis UltraSound Classic (2.4)");
        if ((val != 255 && (val & 0x06)) || (rev >= 5 && rev != 255)) {
                if (rev >= 5 && rev <= 9) {
                        gus->ics_flag = 1;
@@ -360,16 +360,16 @@ static int snd_gus_check_version(struct snd_gus_card * gus)
                }
                if (rev >= 10 && rev != 255) {
                        if (rev >= 10 && rev <= 11) {
-                               strcpy(card->driver, "GUS MAX");
-                               strcpy(card->longname, "Gravis UltraSound MAX");
+                               strscpy(card->driver, "GUS MAX");
+                               strscpy(card->longname, "Gravis UltraSound MAX");
                                gus->max_flag = 1;
                        } else if (rev == 0x30) {
-                               strcpy(card->driver, "GUS ACE");
-                               strcpy(card->longname, "Gravis UltraSound Ace");
+                               strscpy(card->driver, "GUS ACE");
+                               strscpy(card->longname, "Gravis UltraSound Ace");
                                gus->ace_flag = 1;
                        } else if (rev == 0x50) {
-                               strcpy(card->driver, "GUS Extreme");
-                               strcpy(card->longname, "Gravis UltraSound Extreme");
+                               strscpy(card->driver, "GUS Extreme");
+                               strscpy(card->longname, "Gravis UltraSound Extreme");
                                gus->ess_flag = 1;
                        } else {
                                dev_err(card->dev,
index 03f9cfcbf6010caa2026f59c96a358950af118dd..60c3a8219770d93d523956a34bd60d8d2bdd013e 100644 (file)
@@ -152,7 +152,7 @@ int snd_gf1_new_mixer(struct snd_gus_card * gus)
        if (gus->ics_flag)
                snd_component_add(card, "ICS2101");
        if (card->mixername[0] == '\0') {
-               strcpy(card->mixername, gus->ics_flag ? "GF1,ICS2101" : "GF1");
+               strscpy(card->mixername, gus->ics_flag ? "GF1,ICS2101" : "GF1");
        } else {
                if (gus->ics_flag)
                        strcat(card->mixername, ",ICS2101");
index 16f9bbb43a5442a25bfcdeaafc674dd626564c2f..8b9b7b8d92b22c545987909b3b9ef92055482465 100644 (file)
@@ -851,7 +851,7 @@ int snd_gf1_pcm_new(struct snd_gus_card *gus, int pcm_dev, int control_index)
                                           SNDRV_DMA_TYPE_DEV, card->dev,
                                           64*1024, gus->gf1.dma2 > 3 ? 128*1024 : 64*1024);
        }
-       strcpy(pcm->name, pcm->id);
+       strscpy(pcm->name, pcm->id);
        if (gus->interwave) {
                sprintf(pcm->name + strlen(pcm->name), " rev %c", gus->revision + 'A');
        }
index 047ddbc6192fcafb9119395fb51662be1677a145..7267fb5bf8e5ecabd40f30f893640a3f836d8a60 100644 (file)
@@ -156,7 +156,7 @@ void snd_gf1_timers_init(struct snd_gus_card * gus)
        tid.subdevice = 0;
 
        if (snd_timer_new(gus->card, "GF1 timer", &tid, &timer) >= 0) {
-               strcpy(timer->name, "GF1 timer #1");
+               strscpy(timer->name, "GF1 timer #1");
                timer->private_data = gus;
                timer->private_free = snd_gf1_timer1_free;
                timer->hw = snd_gf1_timer1;
@@ -166,7 +166,7 @@ void snd_gf1_timers_init(struct snd_gus_card * gus)
        tid.device++;
 
        if (snd_timer_new(gus->card, "GF1 timer", &tid, &timer) >= 0) {
-               strcpy(timer->name, "GF1 timer #2");
+               strscpy(timer->name, "GF1 timer #2");
                timer->private_data = gus;
                timer->private_free = snd_gf1_timer2_free;
                timer->hw = snd_gf1_timer2;
index 08276509447fe91057e6b9881dc079547e13e590..e207f274f240f968750b6580f5567471a0dd5c3d 100644 (file)
@@ -236,7 +236,7 @@ int snd_gf1_rawmidi_new(struct snd_gus_card *gus, int device)
        err = snd_rawmidi_new(gus->card, "GF1", device, 1, 1, &rmidi);
        if (err < 0)
                return err;
-       strcpy(rmidi->name, gus->interwave ? "AMD InterWave" : "GF1");
+       strscpy(rmidi->name, gus->interwave ? "AMD InterWave" : "GF1");
        snd_rawmidi_set_ops(rmidi, SNDRV_RAWMIDI_STREAM_OUTPUT, &snd_gf1_uart_output);
        snd_rawmidi_set_ops(rmidi, SNDRV_RAWMIDI_STREAM_INPUT, &snd_gf1_uart_input);
        rmidi->info_flags |= SNDRV_RAWMIDI_INFO_OUTPUT | SNDRV_RAWMIDI_INFO_INPUT | SNDRV_RAWMIDI_INFO_DUPLEX;
index 6eab95bd49c1d6ef38bec531ff944d803e2328ef..28827a2e6cbdbfbc26028d6e811a518a299d1ec0 100644 (file)
@@ -204,15 +204,15 @@ static int snd_gusextreme_mixer(struct snd_card *card)
        id1.iface = id2.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
 
        /* reassign AUX to SYNTHESIZER */
-       strcpy(id1.name, "Aux Playback Volume");
-       strcpy(id2.name, "Synth Playback Volume");
+       strscpy(id1.name, "Aux Playback Volume");
+       strscpy(id2.name, "Synth Playback Volume");
        error = snd_ctl_rename_id(card, &id1, &id2);
        if (error < 0)
                return error;
 
        /* reassign Master Playback Switch to Synth Playback Switch */
-       strcpy(id1.name, "Master Playback Switch");
-       strcpy(id2.name, "Synth Playback Switch");
+       strscpy(id1.name, "Master Playback Switch");
+       strscpy(id2.name, "Synth Playback Switch");
        error = snd_ctl_rename_id(card, &id1, &id2);
        if (error < 0)
                return error;
index 445fd2fb50f102e44c704ec499d69d11f0fb53d4..b572411c442289b348a2c6cb458e5d5deec506f5 100644 (file)
@@ -134,24 +134,24 @@ static int snd_gusmax_mixer(struct snd_wss *chip)
        memset(&id2, 0, sizeof(id2));
        id1.iface = id2.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
        /* reassign AUXA to SYNTHESIZER */
-       strcpy(id1.name, "Aux Playback Switch");
-       strcpy(id2.name, "Synth Playback Switch");
+       strscpy(id1.name, "Aux Playback Switch");
+       strscpy(id2.name, "Synth Playback Switch");
        err = snd_ctl_rename_id(card, &id1, &id2);
        if (err < 0)
                return err;
-       strcpy(id1.name, "Aux Playback Volume");
-       strcpy(id2.name, "Synth Playback Volume");
+       strscpy(id1.name, "Aux Playback Volume");
+       strscpy(id2.name, "Synth Playback Volume");
        err = snd_ctl_rename_id(card, &id1, &id2);
        if (err < 0)
                return err;
        /* reassign AUXB to CD */
-       strcpy(id1.name, "Aux Playback Switch"); id1.index = 1;
-       strcpy(id2.name, "CD Playback Switch");
+       strscpy(id1.name, "Aux Playback Switch"); id1.index = 1;
+       strscpy(id2.name, "CD Playback Switch");
        err = snd_ctl_rename_id(card, &id1, &id2);
        if (err < 0)
                return err;
-       strcpy(id1.name, "Aux Playback Volume");
-       strcpy(id2.name, "CD Playback Volume");
+       strscpy(id1.name, "Aux Playback Volume");
+       strscpy(id2.name, "CD Playback Volume");
        err = snd_ctl_rename_id(card, &id1, &id2);
        if (err < 0)
                return err;
index 18a98123e2867c4ec50b39370a4d8d75a067d413..0e0bcd85a648df2fcb18b6571ef61f7fd19a5f74 100644 (file)
@@ -271,7 +271,7 @@ static int snd_interwave_detect(struct snd_interwave *iwcard,
                dev_dbg(gus->card->dev,
                        "[0x%lx] InterWave check - passed\n", gus->gf1.port);
                gus->interwave = 1;
-               strcpy(gus->card->shortname, "AMD InterWave");
+               strscpy(gus->card->shortname, "AMD InterWave");
                gus->revision = rev1 >> 4;
 #ifndef SNDRV_STB
                return 0;       /* ok.. We have an InterWave board */
@@ -500,11 +500,11 @@ static int snd_interwave_mixer(struct snd_wss *chip)
        id1.iface = id2.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
 #if 0
        /* remove mono microphone controls */
-       strcpy(id1.name, "Mic Playback Switch");
+       strscpy(id1.name, "Mic Playback Switch");
        err = snd_ctl_remove_id(card, &id1);
        if (err < 0)
                return err;
-       strcpy(id1.name, "Mic Playback Volume");
+       strscpy(id1.name, "Mic Playback Volume");
        err = snd_ctl_remove_id(card, &id1);
        if (err < 0)
                return err;
@@ -520,24 +520,24 @@ static int snd_interwave_mixer(struct snd_wss *chip)
        snd_wss_out(chip, CS4231_LEFT_MIC_INPUT, 0x9f);
        snd_wss_out(chip, CS4231_RIGHT_MIC_INPUT, 0x9f);
        /* reassign AUXA to SYNTHESIZER */
-       strcpy(id1.name, "Aux Playback Switch");
-       strcpy(id2.name, "Synth Playback Switch");
+       strscpy(id1.name, "Aux Playback Switch");
+       strscpy(id2.name, "Synth Playback Switch");
        err = snd_ctl_rename_id(card, &id1, &id2);
        if (err < 0)
                return err;
-       strcpy(id1.name, "Aux Playback Volume");
-       strcpy(id2.name, "Synth Playback Volume");
+       strscpy(id1.name, "Aux Playback Volume");
+       strscpy(id2.name, "Synth Playback Volume");
        err = snd_ctl_rename_id(card, &id1, &id2);
        if (err < 0)
                return err;
        /* reassign AUXB to CD */
-       strcpy(id1.name, "Aux Playback Switch"); id1.index = 1;
-       strcpy(id2.name, "CD Playback Switch");
+       strscpy(id1.name, "Aux Playback Switch"); id1.index = 1;
+       strscpy(id2.name, "CD Playback Switch");
        err = snd_ctl_rename_id(card, &id1, &id2);
        if (err < 0)
                return err;
-       strcpy(id1.name, "Aux Playback Volume");
-       strcpy(id2.name, "CD Playback Volume");
+       strscpy(id1.name, "Aux Playback Volume");
+       strscpy(id2.name, "CD Playback Volume");
        err = snd_ctl_rename_id(card, &id1, &id2);
        if (err < 0)
                return err;
@@ -713,14 +713,14 @@ static int snd_interwave_probe(struct snd_card *card, int dev,
                memset(&id1, 0, sizeof(id1));
                memset(&id2, 0, sizeof(id2));
                id1.iface = id2.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
-               strcpy(id1.name, "Master Playback Switch");
-               strcpy(id2.name, id1.name);
+               strscpy(id1.name, "Master Playback Switch");
+               strscpy(id2.name, id1.name);
                id2.index = 1;
                err = snd_ctl_rename_id(card, &id1, &id2);
                if (err < 0)
                        return err;
-               strcpy(id1.name, "Master Playback Volume");
-               strcpy(id2.name, id1.name);
+               strscpy(id1.name, "Master Playback Volume");
+               strscpy(id2.name, id1.name);
                err = snd_ctl_rename_id(card, &id1, &id2);
                if (err < 0)
                        return err;
@@ -742,8 +742,8 @@ static int snd_interwave_probe(struct snd_card *card, int dev,
 #else
        str = "InterWave STB";
 #endif
-       strcpy(card->driver, str);
-       strcpy(card->shortname, str);
+       strscpy(card->driver, str);
+       strscpy(card->shortname, str);
        sprintf(card->longname, "%s at 0x%lx, irq %i, dma %d",
                str,
                gus->gf1.port,