Skip to content

Commit ca3b7b9

Browse files
tiwaibroonie
authored andcommitted
ASoC: Intel: avs: Fix potential buffer overflow by snprintf()
snprintf() returns the would-be-filled size when the string overflows the given buffer size, hence using this value may result in a buffer overflow (although it's unrealistic). This patch replaces it with a safer version, scnprintf() for papering over such a potential issue. Fixes: f1b3b32 ("ASoC: Intel: avs: Generic soc component driver") Signed-off-by: Takashi Iwai <[email protected]> Acked-by: Cezary Rojewski <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent c0fc96f commit ca3b7b9

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

sound/soc/intel/avs/pcm.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -636,8 +636,8 @@ static ssize_t topology_name_read(struct file *file, char __user *user_buf, size
636636
char buf[64];
637637
size_t len;
638638

639-
len = snprintf(buf, sizeof(buf), "%s/%s\n", component->driver->topology_name_prefix,
640-
mach->tplg_filename);
639+
len = scnprintf(buf, sizeof(buf), "%s/%s\n", component->driver->topology_name_prefix,
640+
mach->tplg_filename);
641641

642642
return simple_read_from_buffer(user_buf, count, ppos, buf, len);
643643
}

0 commit comments

Comments
 (0)