]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ALSA: firewire: dice: Use safer strscpy() instead of strcpy()
authorTakashi Iwai <tiwai@suse.de>
Thu, 10 Jul 2025 10:05:56 +0000 (12:05 +0200)
committerTakashi Iwai <tiwai@suse.de>
Fri, 11 Jul 2025 07:52:27 +0000 (09:52 +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>
Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://patch.msgid.link/20250710100727.22653-15-tiwai@suse.de
sound/firewire/dice/dice-hwdep.c
sound/firewire/dice/dice-pcm.c
sound/firewire/dice/dice.c

index ffc0b97782d6319f7c840c89134566bff870898f..d165dd427bd3b9ef9a951a373c104c48b913e223 100644 (file)
@@ -179,7 +179,7 @@ int snd_dice_create_hwdep(struct snd_dice *dice)
        err = snd_hwdep_new(dice->card, "DICE", 0, &hwdep);
        if (err < 0)
                return err;
-       strcpy(hwdep->name, "DICE");
+       strscpy(hwdep->name, "DICE");
        hwdep->iface = SNDRV_HWDEP_IFACE_FW_DICE;
        hwdep->ops = ops;
        hwdep->private_data = dice;
index 2cf2adb48f2a6d1cf1e45a893f06cd7261638c95..cfc19bd0d5dd4e6136d290925493b8101d28e3c4 100644 (file)
@@ -442,7 +442,7 @@ int snd_dice_create_pcm(struct snd_dice *dice)
                        return err;
                pcm->private_data = dice;
                pcm->nonatomic = true;
-               strcpy(pcm->name, dice->card->shortname);
+               strscpy(pcm->name, dice->card->shortname);
 
                if (capture > 0)
                        snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE,
index d362e4251c688bcfe715efe91066dfbae44b2c72..9675ec14271d04e7d1520e1919a0175131584b35 100644 (file)
@@ -102,9 +102,9 @@ static void dice_card_strings(struct snd_dice *dice)
        unsigned int i;
        int err;
 
-       strcpy(card->driver, "DICE");
+       strscpy(card->driver, "DICE");
 
-       strcpy(card->shortname, "DICE");
+       strscpy(card->shortname, "DICE");
        BUILD_BUG_ON(NICK_NAME_SIZE < sizeof(card->shortname));
        err = snd_dice_transaction_read_global(dice, GLOBAL_NICK_NAME,
                                               card->shortname,
@@ -117,16 +117,16 @@ static void dice_card_strings(struct snd_dice *dice)
                card->shortname[sizeof(card->shortname) - 1] = '\0';
        }
 
-       strcpy(vendor, "?");
+       strscpy(vendor, "?");
        fw_csr_string(dev->config_rom + 5, CSR_VENDOR, vendor, sizeof(vendor));
-       strcpy(model, "?");
+       strscpy(model, "?");
        fw_csr_string(dice->unit->directory, CSR_MODEL, model, sizeof(model));
        snprintf(card->longname, sizeof(card->longname),
                 "%s %s (serial %u) at %s, S%d",
                 vendor, model, dev->config_rom[4] & 0x3fffff,
                 dev_name(&dice->unit->device), 100 << dev->max_speed);
 
-       strcpy(card->mixername, "DICE");
+       strscpy(card->mixername, "DICE");
 }
 
 static void dice_card_free(struct snd_card *card)