Commit 9876e386 authored by Takashi Iwai's avatar Takashi Iwai Committed by Jens Axboe
Browse files

bcache: Use scnprintf() for avoiding potential buffer overflow



Since snprintf() returns the would-be-output size instead of the
actual output size, the succeeding calls may go beyond the given
buffer limit.  Fix it by replacing with scnprintf().

Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
Signed-off-by: default avatarColy Li <colyli@suse.de>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent b144e45f
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -154,7 +154,7 @@ static ssize_t bch_snprint_string_list(char *buf,
	size_t i;

	for (i = 0; list[i]; i++)
		out += snprintf(out, buf + size - out,
		out += scnprintf(out, buf + size - out,
				i == selected ? "[%s] " : "%s ", list[i]);

	out[-1] = '\n';