Skip to content

Commit 94c1ceb

Browse files
tiwaibroonie
authored andcommitted
ASoC: SOF: Intel: hda: 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 the buffer overflow (although it's unrealistic). This patch replaces with a safer version, scnprintf() for papering over such a potential issue. Fixes: 29c8e43 ("ASoC: SOF: Intel: hda: add extended rom status dump to error log") Signed-off-by: Takashi Iwai <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 1eb123c commit 94c1ceb

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

sound/soc/sof/intel/hda.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ static void hda_dsp_dump_ext_rom_status(struct snd_sof_dev *sdev, const char *le
574574
chip = get_chip_info(sdev->pdata);
575575
for (i = 0; i < HDA_EXT_ROM_STATUS_SIZE; i++) {
576576
value = snd_sof_dsp_read(sdev, HDA_DSP_BAR, chip->rom_status_reg + i * 0x4);
577-
len += snprintf(msg + len, sizeof(msg) - len, " 0x%x", value);
577+
len += scnprintf(msg + len, sizeof(msg) - len, " 0x%x", value);
578578
}
579579

580580
dev_printk(level, sdev->dev, "extended rom status: %s", msg);

0 commit comments

Comments
 (0)