]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ALSA: intel8x0: Use safer strscpy() instead of strcpy()
authorTakashi Iwai <tiwai@suse.de>
Thu, 10 Jul 2025 10:06:50 +0000 (12:06 +0200)
committerTakashi Iwai <tiwai@suse.de>
Fri, 11 Jul 2025 07:53:21 +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-69-tiwai@suse.de
sound/pci/intel8x0.c
sound/pci/intel8x0m.c

index b521cec2033361b59b7abf5012ec65c532d9d7a3..9e6a5065ffbf568317a86b2bf9f6c43d39141155 100644 (file)
@@ -1436,7 +1436,7 @@ static int snd_intel8x0_pcm1(struct intel8x0 *chip, int device,
        if (rec->suffix)
                sprintf(name, "Intel ICH - %s", rec->suffix);
        else
-               strcpy(name, "Intel ICH");
+               strscpy(name, "Intel ICH");
        err = snd_pcm_new(chip->card, name, device,
                          rec->playback_ops ? 1 : 0,
                          rec->capture_ops ? 1 : 0, &pcm);
@@ -1453,7 +1453,7 @@ static int snd_intel8x0_pcm1(struct intel8x0 *chip, int device,
        if (rec->suffix)
                sprintf(pcm->name, "%s - %s", chip->card->shortname, rec->suffix);
        else
-               strcpy(pcm->name, chip->card->shortname);
+               strscpy(pcm->name, chip->card->shortname);
        chip->pcm[device] = pcm;
 
        snd_pcm_set_managed_buffer_all(pcm, intel8x0_dma_type(chip),
@@ -3118,21 +3118,21 @@ static int __snd_intel8x0_probe(struct pci_dev *pci,
        if (spdif_aclink < 0)
                spdif_aclink = check_default_spdif_aclink(pci);
 
-       strcpy(card->driver, "ICH");
+       strscpy(card->driver, "ICH");
        if (!spdif_aclink) {
                switch (pci_id->driver_data) {
                case DEVICE_NFORCE:
-                       strcpy(card->driver, "NFORCE");
+                       strscpy(card->driver, "NFORCE");
                        break;
                case DEVICE_INTEL_ICH4:
-                       strcpy(card->driver, "ICH4");
+                       strscpy(card->driver, "ICH4");
                }
        }
 
-       strcpy(card->shortname, "Intel ICH");
+       strscpy(card->shortname, "Intel ICH");
        for (name = shortnames; name->id; name++) {
                if (pci->device == name->id) {
-                       strcpy(card->shortname, name->s);
+                       strscpy(card->shortname, name->s);
                        break;
                }
        }
index 1ce775fe8a70ce37f5ca0f1876c8c56baeb827d1..9e5988583abe9166e6e3b0c3c146f8766ec55279 100644 (file)
@@ -678,7 +678,7 @@ static int snd_intel8x0m_pcm1(struct intel8x0m *chip, int device,
        if (rec->suffix)
                sprintf(name, "Intel ICH - %s", rec->suffix);
        else
-               strcpy(name, "Intel ICH");
+               strscpy(name, "Intel ICH");
        err = snd_pcm_new(chip->card, name, device,
                          rec->playback_ops ? 1 : 0,
                          rec->capture_ops ? 1 : 0, &pcm);
@@ -696,7 +696,7 @@ static int snd_intel8x0m_pcm1(struct intel8x0m *chip, int device,
        if (rec->suffix)
                sprintf(pcm->name, "%s - %s", chip->card->shortname, rec->suffix);
        else
-               strcpy(pcm->name, chip->card->shortname);
+               strscpy(pcm->name, chip->card->shortname);
        chip->pcm[device] = pcm;
 
        snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV,
@@ -1184,11 +1184,11 @@ static int __snd_intel8x0m_probe(struct pci_dev *pci,
                return err;
        chip = card->private_data;
 
-       strcpy(card->driver, "ICH-MODEM");
-       strcpy(card->shortname, "Intel ICH");
+       strscpy(card->driver, "ICH-MODEM");
+       strscpy(card->shortname, "Intel ICH");
        for (name = shortnames; name->id; name++) {
                if (pci->device == name->id) {
-                       strcpy(card->shortname, name->s);
+                       strscpy(card->shortname, name->s);
                        break;
                }
        }