diff options
author | Takashi Iwai <tiwai@suse.de> | 2020-03-22 14:03:03 +0800 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2020-03-22 10:06:57 -0600 |
commit | 9876e38609a8ea98bbb447eb5a8f1c0400a6ccb8 (patch) | |
tree | c8cd41f891b631399a578b22e7fd1ce115441f82 /drivers/md | |
parent | b144e45fc57649e15cbc79ff2d32a942af1d91d5 (diff) | |
download | linux-9876e38609a8ea98bbb447eb5a8f1c0400a6ccb8.tar.gz linux-9876e38609a8ea98bbb447eb5a8f1c0400a6ccb8.tar.bz2 linux-9876e38609a8ea98bbb447eb5a8f1c0400a6ccb8.zip |
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: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Coly Li <colyli@suse.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'drivers/md')
-rw-r--r-- | drivers/md/bcache/sysfs.c | 2 |
1 files changed, 1 insertions, 1 deletions
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'; |