From: Grant Likely <grant.likely@secretlab.ca>
To: qemu-devel@nongnu.org, devicetree-discuss@lists.ozlabs.org,
jeremy.kerr@canonical.com
Subject: [Qemu-devel] [RFC PATCH] devicetree: Fix buffer overflow on setting device node name
Date: Wed, 07 Apr 2010 19:51:42 -0600 [thread overview]
Message-ID: <20100408015013.18100.89239.stgit@angua> (raw)
Fix bug where temporary buffer for sprintf() was not large enough
when setting a device tree node name.
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
---
Hi Jeremy. Here's the fix I promised. With this change your current tree
works beautifully. I've pushed out the kernel that works with this QEMU
branch to my Linux kernel git tree:
git://git.secretlab.ca/git/linux-2.6 test-devicetree
Cheers,
g.
hw/qdev.c | 2 +-
hw/sysbus.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/hw/qdev.c b/hw/qdev.c
index caa5b35..36582ec 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -868,7 +868,7 @@ static int qdev_fdt_add_device(void *fdt, DeviceState *dev, int bus_offset)
{
BusState *child;
int dev_offset, rc;
- char name[sizeof(dev->info->name) + 9];
+ char name[sizeof(dev->info->name) + 20];
static int unique = 0;
sprintf(name, "%s@%x", dev->info->name, unique++);
diff --git a/hw/sysbus.c b/hw/sysbus.c
index c63deef..c17d12d 100644
--- a/hw/sysbus.c
+++ b/hw/sysbus.c
@@ -230,7 +230,7 @@ static int sysbus_fdt_populate_node(DeviceState *dev, void *fdt, int offset)
for (i = 0; i < s->num_mmio; i++) {
/* By convention, the name is appended with '@<first reg addr>' */
if (i == 0) {
- char n[sizeof(dev->info->name) + 10];
+ char n[sizeof(dev->info->name) + 20];
sprintf(n, "%s@%x", dev->info->name, (uint32_t)s->mmio[i].addr);
rc = fdt_set_name(fdt, offset, n);
if (rc < 0)
next reply other threads:[~2010-04-08 1:51 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-08 1:51 Grant Likely [this message]
2010-04-08 3:48 ` [Qemu-devel] Re: [RFC PATCH] devicetree: Fix buffer overflow on setting device node name Jeremy Kerr
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=20100408015013.18100.89239.stgit@angua \
--to=grant.likely@secretlab.ca \
--cc=devicetree-discuss@lists.ozlabs.org \
--cc=jeremy.kerr@canonical.com \
--cc=qemu-devel@nongnu.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;
as well as URLs for NNTP newsgroup(s).