ASoC: SOF: debug: Fix potential buffer overflow by snprintf()
authorTakashi Iwai <tiwai@suse.de>
Mon, 1 Aug 2022 16:54:19 +0000 (18:54 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 25 Aug 2022 09:40:19 +0000 (11:40 +0200)
commitb318b9dd2ac67f39d0338ce563879d1f59a0347a
treec7f1a41e7b78cd3f53fd7fec9860ec5a4fbab905
parent743dc4377bbac06a6fe44c3c5baf75a49439678a
ASoC: SOF: debug: Fix potential buffer overflow by snprintf()

commit 1eb123ce985e6cf302ac6e3f19862d132d86fa8f upstream.

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: 5b10b6298921 ("ASoC: SOF: Add `memory_info` file to debugfs")
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://lore.kernel.org/r/20220801165420.25978-3-tiwai@suse.de
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
sound/soc/sof/debug.c