aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaroslav Kysela <[email protected]>2024-07-05 09:58:28 +0200
committerTakashi Iwai <[email protected]>2024-07-05 10:02:07 +0200
commita892b700e63bcb3679ebed1a0c3160e7b9225138 (patch)
tree743af937f2e4c036e23a39958050834865dd1a24
parentbc7540b794df29f6ec0b24996381d6e68779d02f (diff)
ALSA: pcm: Fix id copying in snd_pcm_set_sync_per_card()
Avoid to use strncpy and do proper length limiting (12 bytes) to avoid out of array access. Fixes: d712c58c55d9 ("ALSA: pcm: optimize and clarify stream synchronization ID API") Reported-by: kernel test robot <[email protected]> Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/ Signed-off-by: Jaroslav Kysela <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
-rw-r--r--sound/core/pcm_lib.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c
index 66683656fb13..6e7905749c4a 100644
--- a/sound/core/pcm_lib.c
+++ b/sound/core/pcm_lib.c
@@ -543,8 +543,8 @@ void snd_pcm_set_sync_per_card(struct snd_pcm_substream *substream,
const unsigned char *id, unsigned int len)
{
*(__u32 *)params->sync = cpu_to_le32(substream->pcm->card->number);
- len = max(12, len);
- strncpy(params->sync + 4, id, len);
+ len = min(12, len);
+ memcpy(params->sync + 4, id, len);
memset(params->sync + 4 + len, 0, 12 - len);
}
EXPORT_SYMBOL_GPL(snd_pcm_set_sync_per_card);