ASoC: SOF: Intel: hda: Fix potential buffer overflow by snprintf()
authorTakashi Iwai <tiwai@suse.de>
Mon, 1 Aug 2022 16:54:20 +0000 (18:54 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 25 Aug 2022 09:40:28 +0000 (11:40 +0200)
commit6ee1310f4d148dbf04c4159b88afd0b941018903
treeed18a0e9af39780b0cb26d21de49d4b7dc7fea10
parent3142b5f09e55f3916e5863f352751f4a27f7c8e4
ASoC: SOF: Intel: hda: Fix potential buffer overflow by snprintf()

[ Upstream commit 94c1ceb043c1a002de9649bb630c8e8347645982 ]

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: 29c8e4398f02 ("ASoC: SOF: Intel: hda: add extended rom status dump to error log")
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://lore.kernel.org/r/20220801165420.25978-4-tiwai@suse.de
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
sound/soc/sof/intel/hda.c