summaryrefslogtreecommitdiffstats
path: root/sound/pci/hda/hda_codec.c
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2020-02-18 10:14:09 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-02-28 16:35:51 +0100
commitfeb0b94a36b3aa610841d13017bc8c64148a01e0 (patch)
treee0d9a5c85b89394088263b31b1e09668843a4ebf /sound/pci/hda/hda_codec.c
parentf16be63f67450e6964cd90878d875f1b9eb2be6e (diff)
downloadlinux-stable-feb0b94a36b3aa610841d13017bc8c64148a01e0.tar.gz
linux-stable-feb0b94a36b3aa610841d13017bc8c64148a01e0.tar.bz2
linux-stable-feb0b94a36b3aa610841d13017bc8c64148a01e0.zip
ALSA: hda: Use scnprintf() for printing texts for sysfs/procfs
commit 44eeb081b8630bb3ad3cd381d1ae1831463e48bb upstream. Some code in HD-audio driver calls snprintf() in a loop and still expects that the return value were actually written size, while snprintf() returns the expected would-be length instead. When the given buffer limit were small, this leads to a buffer overflow. Use scnprintf() for addressing those issues. It returns the actually written size unlike snprintf(). Cc: <stable@vger.kernel.org> Link: https://lore.kernel.org/r/20200218091409.27162-1-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'sound/pci/hda/hda_codec.c')
-rw-r--r--sound/pci/hda/hda_codec.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index e3f3351da480..a6f7561e7bb9 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -4002,7 +4002,7 @@ void snd_print_pcm_bits(int pcm, char *buf, int buflen)
for (i = 0, j = 0; i < ARRAY_SIZE(bits); i++)
if (pcm & (AC_SUPPCM_BITS_8 << i))
- j += snprintf(buf + j, buflen - j, " %d", bits[i]);
+ j += scnprintf(buf + j, buflen - j, " %d", bits[i]);
buf[j] = '\0'; /* necessary when j == 0 */
}