Skip to content

Commit a892b70

Browse files
perexgtiwai
authored andcommitted
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: d712c58 ("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]>
1 parent bc7540b commit a892b70

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

sound/core/pcm_lib.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -543,8 +543,8 @@ void snd_pcm_set_sync_per_card(struct snd_pcm_substream *substream,
543543
const unsigned char *id, unsigned int len)
544544
{
545545
*(__u32 *)params->sync = cpu_to_le32(substream->pcm->card->number);
546-
len = max(12, len);
547-
strncpy(params->sync + 4, id, len);
546+
len = min(12, len);
547+
memcpy(params->sync + 4, id, len);
548548
memset(params->sync + 4 + len, 0, 12 - len);
549549
}
550550
EXPORT_SYMBOL_GPL(snd_pcm_set_sync_per_card);

0 commit comments

Comments
 (0)