Linux bcache driver list
 help / color / mirror / Atom feed
* [PATCH] bcache: Use scnprintf() for avoiding potential buffer overflow
@ 2020-03-11  7:45 Takashi Iwai
  2020-03-19 15:58 ` Takashi Iwai
  0 siblings, 1 reply; 5+ messages in thread
From: Takashi Iwai @ 2020-03-11  7:45 UTC (permalink / raw)
  To: Coly Li, Kent Overstreet; +Cc: linux-bcache

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: Takashi Iwai <tiwai@suse.de>
---
 drivers/md/bcache/sysfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/md/bcache/sysfs.c b/drivers/md/bcache/sysfs.c
index 3470fae4eabc..323276994aab 100644
--- a/drivers/md/bcache/sysfs.c
+++ b/drivers/md/bcache/sysfs.c
@@ -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';
-- 
2.16.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-03-19 16:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-03-11  7:45 [PATCH] bcache: Use scnprintf() for avoiding potential buffer overflow Takashi Iwai
2020-03-19 15:58 ` Takashi Iwai
2020-03-19 16:27   ` Coly Li
2020-03-19 16:28     ` Takashi Iwai
2020-03-19 16:32       ` Coly Li

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox