mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 3/5] Fix memory corruption bug in dev_id()
Date: Thu, 28 Jul 2011 09:58:18 +0200	[thread overview]
Message-ID: <1311839900-10389-4-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1311839900-10389-1-git-send-email-s.hauer@pengutronix.de>

The size of the static buffer in dev_id was only 8 bytes
(sizeof(long) * 2). This is completely bogus, so give
the buffer a sane length and also make sure we don't
write beyond the buffer using snprintf.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/base/driver.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index b5166c8..bb6df3c 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -284,9 +284,9 @@ EXPORT_SYMBOL(dummy_probe);
 
 const char *dev_id(const struct device_d *dev)
 {
-	static char buf[sizeof(unsigned long) * 2];
+	static char buf[MAX_DRIVER_NAME + 16];
 
-	sprintf(buf, FORMAT_DRIVER_MANE_ID, dev->name, dev->id);
+	snprintf(buf, sizeof(buf), FORMAT_DRIVER_MANE_ID, dev->name, dev->id);
 
 	return buf;
 }
-- 
1.7.5.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2011-07-28  7:58 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-28  7:58 fixes for -next Sascha Hauer
2011-07-28  7:58 ` [PATCH 1/5] net: remove unused fields from struct eth_device Sascha Hauer
2011-07-28  7:58 ` [PATCH 2/5] ARM i.MX: Add missing cpu_is_mx53() Sascha Hauer
2011-07-28  7:58 ` Sascha Hauer [this message]
2011-07-28  7:58 ` [PATCH 4/5] fix typo Sascha Hauer
2011-07-28  7:58 ` [PATCH 5/5] mci: do not use unitialized resource Sascha Hauer

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=1311839900-10389-4-git-send-email-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.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