public inbox for linux-bcache@vger.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
To: koverstreet-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org
Cc: linux-bcache-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: re: bcache: A block layer cache
Date: Mon, 1 Apr 2013 22:37:41 +0300	[thread overview]
Message-ID: <20130401193740.GA32549@longonot.mountain> (raw)

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"

drivers/md/bcache/util.c
    77  ssize_t hprint(char *buf, int64_t v)
    78  {
    79          static const char units[] = "?kMGTPEZY";
    80          char dec[3] = "";
    81          int u, t = 0;
    82  
    83          for (u = 0; v >= 1024 || v <= -1024; u++) {
    84                  t = v & ~(~0 << 10);
    85                  v >>= 10;
    86          }
    87  
    88          if (!u)
    89                  return sprintf(buf, "%llu", v);
    90  
    91          if (v < 100 && v > -100)
    92                  sprintf(dec, ".%i", t / 100);

For example, hprint(buf, 2024) will cause a one char buffer overflow.

    93  
    94          return sprintf(buf, "%lli%s%c", v, dec, units[u]);

regards,
dan carpenter

             reply	other threads:[~2013-04-01 19:37 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-01 19:37 Dan Carpenter [this message]
     [not found] ` <20130401193740.GA32549-dZEljifmRObu9KfB+GxooP8+0UxHXcjY@public.gmane.org>
2013-04-01 19:58   ` bcache: A block layer cache Dan Carpenter
2013-04-05 21:14   ` Kent Overstreet

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130401193740.GA32549@longonot.mountain \
    --to=dan.carpenter-qhclzuegtsvqt0dzr+alfa@public.gmane.org \
    --cc=koverstreet-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org \
    --cc=linux-bcache-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox