[PATCH 3/7] ALSA: cmipci: replace strlcat() with strscpy()
Mahad Ibrahim <[email protected]>
| Newsgroups | org.kernel.vger.linux-sound,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
The "-SWIEC" suffix on card->driver was appended with strlcat(). Take the length of the existing driver name and write the suffix at that offset with strscpy(). This is the same thing the can_multi_ch branch immediately above already does, so both arms of the conditional now build the name the same way. strlcat() and strscpy() both truncate at the end of the buffer, and the suffix is written at the same offset either way. Signed-off-by: Mahad Ibrahim <[email protected]> --- sound/pci/cmipci.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sound/pci/cmipci.c b/sound/pci/cmipci.c index 9d9f784e3a8c..c8d98d76b689 100644 --- a/sound/pci/cmipci.c +++ b/sound/pci/cmipci.c @@ -2983,8 +2983,12 @@ static int snd_cmipci_create(struct snd_card *card, struct pci_dev *pci, int l = strlen(cm->card->driver); scnprintf(cm->card->driver + l, sizeof(cm->card->driver) - l, "-MC%d", cm->max_channels); - } else if (cm->can_ac3_sw) - strlcat(cm->card->driver, "-SWIEC", sizeof(cm->card->driver)); + } else if (cm->can_ac3_sw) { + int l = strlen(cm->card->driver); + + strscpy(cm->card->driver + l, "-SWIEC", + sizeof(cm->card->driver) - l); + } cm->dig_status = SNDRV_PCM_DEFAULT_CON_SPDIF; cm->dig_pcm_status = SNDRV_PCM_DEFAULT_CON_SPDIF; -- 2.54.0