summaryrefslogtreecommitdiffstats
path: root/drivers/md/bcache/util.c
diff options
context:
space:
mode:
authorKent Overstreet <koverstreet@google.com>2013-04-05 23:12:28 +0200
committerKent Overstreet <koverstreet@google.com>2013-04-08 22:33:49 +0200
commit91bbcfc36142354e316e013449051619c1c7b456 (patch)
tree1f15ac8564a047d4f2de3f96195aba8898ac5338 /drivers/md/bcache/util.c
parentbcache: Fix a minor memory leak on device teardown (diff)
downloadlinux-91bbcfc36142354e316e013449051619c1c7b456.tar.xz
linux-91bbcfc36142354e316e013449051619c1c7b456.zip
bcache: Fix a format string overflow
Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Kent Overstreet <koverstreet@google.com>
Diffstat (limited to 'drivers/md/bcache/util.c')
-rw-r--r--drivers/md/bcache/util.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/md/bcache/util.c b/drivers/md/bcache/util.c
index a9619d880354..da3a99e85b1e 100644
--- a/drivers/md/bcache/util.c
+++ b/drivers/md/bcache/util.c
@@ -76,7 +76,7 @@ STRTO_H(strtoull, unsigned long long)
ssize_t bch_hprint(char *buf, int64_t v)
{
static const char units[] = "?kMGTPEZY";
- char dec[3] = "";
+ char dec[4] = "";
int u, t = 0;
for (u = 0; v >= 1024 || v <= -1024; u++) {
@@ -88,7 +88,7 @@ ssize_t bch_hprint(char *buf, int64_t v)
return sprintf(buf, "%llu", v);
if (v < 100 && v > -100)
- sprintf(dec, ".%i", t / 100);
+ snprintf(dec, sizeof(dec), ".%i", t / 100);
return sprintf(buf, "%lli%s%c", v, dec, units[u]);
}