diff options
author | Takashi Iwai <tiwai@suse.de> | 2020-02-18 10:14:09 +0100 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2020-02-18 10:15:41 +0100 |
commit | 44eeb081b8630bb3ad3cd381d1ae1831463e48bb (patch) | |
tree | 22799f2d7d68e9a71bca72600a38af044232e299 /sound/pci/hda/hda_codec.c | |
parent | cc5049ae4d457194796f854eb2e38b9727ad8c2d (diff) | |
download | linux-44eeb081b8630bb3ad3cd381d1ae1831463e48bb.tar.gz linux-44eeb081b8630bb3ad3cd381d1ae1831463e48bb.tar.bz2 linux-44eeb081b8630bb3ad3cd381d1ae1831463e48bb.zip |
ALSA: hda: Use scnprintf() for printing texts for sysfs/procfs
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>
Diffstat (limited to 'sound/pci/hda/hda_codec.c')
-rw-r--r-- | sound/pci/hda/hda_codec.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index 5dc42f932739..53e7732ef752 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c @@ -4022,7 +4022,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 */ } |