On Mon, Apr 01, 2013 at 10:37:41PM +0300, Dan Carpenter wrote:
> Hello Kent Overstreet,
> 
> The patch cafe56359144: "bcache: A block layer cache" from Mar 23, 
> 2013, leads to the following warning:
> "drivers/md/bcache/util.c:92 hprint()
>        error: format string overflow. buf_size: 3 length: 4"

Thanks - fixed

commit c20bbfc0e049ca785bb19419121091e4fd419886
Author: Kent Overstreet <[email protected]>
Date:   Fri Apr 5 14:12:28 2013 -0700

    bcache: Fix a format string overflow
    
    Reported-by: Dan Carpenter <[email protected]>
    Signed-off-by: Kent Overstreet <[email protected]>

diff --git a/drivers/md/bcache/util.c b/drivers/md/bcache/util.c
index a9619d8..da3a99e 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]);
 }
--
To unsubscribe from this list: send the line "unsubscribe linux-bcache" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to