From: Clemens Ladisch Date: Thu, 21 Aug 2014 18:55:21 +0000 (+0200) Subject: ALSA: core: fix buffer overflow in snd_info_get_line() X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=ddc64b278a4dda052390b3de1b551e59acdff105;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git ALSA: core: fix buffer overflow in snd_info_get_line() snd_info_get_line() documents that its last parameter must be one less than the buffer size, but this API design guarantees that (literally) every caller gets it wrong. Just change this parameter to have its obvious meaning. Reported-by: Tommi Rantala Cc: # v2.2.26+ Signed-off-by: Clemens Ladisch Signed-off-by: Takashi Iwai --- diff --git a/sound/core/info.c b/sound/core/info.c index 051d55b05521..9f404e965ea2 100644 --- a/sound/core/info.c +++ b/sound/core/info.c @@ -684,7 +684,7 @@ int snd_info_card_free(struct snd_card *card) * snd_info_get_line - read one line from the procfs buffer * @buffer: the procfs buffer * @line: the buffer to store - * @len: the max. buffer size - 1 + * @len: the max. buffer size * * Reads one line from the buffer and stores the string. * @@ -704,7 +704,7 @@ int snd_info_get_line(struct snd_info_buffer *buffer, char *line, int len) buffer->stop = 1; if (c == '\n') break; - if (len) { + if (len > 1) { len--; *line++ = c; }