All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mahad Ibrahim <mahad.ibrahim.dev@gmail.com>
To: Takashi Iwai <tiwai@suse.com>, Jaroslav Kysela <perex@perex.cz>
Cc: Kees Cook <kees@kernel.org>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
	Mahad Ibrahim <mahad.ibrahim.dev@gmail.com>
Subject: [PATCH 3/7] ALSA: cmipci: replace strlcat() with strscpy()
Date: Fri,  7 Aug 2026 11:41:35 +0000	[thread overview]
Message-ID: <20260807114139.1661-4-mahad.ibrahim.dev@gmail.com> (raw)
In-Reply-To: <20260807114139.1661-1-mahad.ibrahim.dev@gmail.com>

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 <mahad.ibrahim.dev@gmail.com>
---
 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


  parent reply	other threads:[~2026-08-07 11:42 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-07 11:41 [PATCH 0/7] ALSA: remove remaining strlcat() users under sound/ Mahad Ibrahim
2026-08-07 11:41 ` [PATCH 1/7] ALSA: ump: replace strlcat() with strscpy() Mahad Ibrahim
2026-08-07 11:41 ` [PATCH 2/7] ALSA: ac97: replace strlcat() with scnprintf() Mahad Ibrahim
2026-08-07 11:41 ` Mahad Ibrahim [this message]
2026-08-07 11:41 ` [PATCH 4/7] ALSA: caiaq: replace strlcat() with strscpy() Mahad Ibrahim
2026-08-07 11:41 ` [PATCH 5/7] ALSA: usb-audio: replace strlcat() with append_ctl_name() Mahad Ibrahim
2026-08-07 11:41 ` [PATCH 6/7] ALSA: hiface: replace strlcat() with scnprintf() Mahad Ibrahim
2026-08-07 11:41 ` [PATCH 7/7] ALSA: usb-audio: replace strlcat() in longname construction Mahad Ibrahim
2026-08-07 12:15 ` [PATCH 0/7] ALSA: remove remaining strlcat() users under sound/ Takashi Iwai
2026-08-07 13:04   ` David Laight
2026-08-07 15:41   ` Mahad Ibrahim
2026-08-07 16:03     ` Takashi Iwai
2026-08-07 21:46       ` Kees Cook
2026-08-08 13:04         ` David Laight

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260807114139.1661-4-mahad.ibrahim.dev@gmail.com \
    --to=mahad.ibrahim.dev@gmail.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=kees@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=tiwai@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.