qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] pci: fix pcibus_get_dev_path()
@ 2011-01-20 10:31 TeLeMan
  2011-01-20 14:21 ` [Qemu-devel] " Michael S. Tsirkin
  0 siblings, 1 reply; 2+ messages in thread
From: TeLeMan @ 2011-01-20 10:31 UTC (permalink / raw)
  To: Michael S. Tsirkin, qemu-devel

The commit 6a7005d14b3c32d4864a718fb1cb19c789f58a5 used snprintf() incorrectly.

Signed-off-by: TeLeMan <geleman@gmail.com>
---
 hw/pci.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/pci.c b/hw/pci.c
index 8d0e3df..9f8800d 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -2050,14 +2050,14 @@ static char *pcibus_get_dev_path(DeviceState *dev)
     path[path_len] = '\0';

     /* First field is the domain. */
-    snprintf(path, domain_len, "%04x:00", pci_find_domain(d->bus));
+    snprintf(path, domain_len + 1, "%04x:00", pci_find_domain(d->bus));

     /* Fill in slot numbers. We walk up from device to root, so need to print
      * them in the reverse order, last to first. */
     p = path + path_len;
     for (t = d; t; t = t->bus->parent_dev) {
         p -= slot_len;
-        snprintf(p, slot_len, ":%02x.%x", PCI_SLOT(t->devfn),
PCI_FUNC(d->devfn));
+        snprintf(p, slot_len + 1, ":%02x.%x", PCI_SLOT(t->devfn),
PCI_FUNC(d->devfn));
     }

     return path;
-- 
1.7.3.1.msysgit.0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [Qemu-devel] Re: [PATCH] pci: fix pcibus_get_dev_path()
  2011-01-20 10:31 [Qemu-devel] [PATCH] pci: fix pcibus_get_dev_path() TeLeMan
@ 2011-01-20 14:21 ` Michael S. Tsirkin
  0 siblings, 0 replies; 2+ messages in thread
From: Michael S. Tsirkin @ 2011-01-20 14:21 UTC (permalink / raw)
  To: TeLeMan; +Cc: qemu-devel

On Thu, Jan 20, 2011 at 06:31:59PM +0800, TeLeMan wrote:
> The commit 6a7005d14b3c32d4864a718fb1cb19c789f58a5 used snprintf() incorrectly.
> 
> Signed-off-by: TeLeMan <geleman@gmail.com>

This won't work for nested bridges as \n by the first
sprintf overwrites the rest of the string.
I sent a fix titled
[PATCH] pci: fix device paths
look it up.

> ---
>  hw/pci.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/pci.c b/hw/pci.c
> index 8d0e3df..9f8800d 100644
> --- a/hw/pci.c
> +++ b/hw/pci.c
> @@ -2050,14 +2050,14 @@ static char *pcibus_get_dev_path(DeviceState *dev)
>      path[path_len] = '\0';
> 
>      /* First field is the domain. */
> -    snprintf(path, domain_len, "%04x:00", pci_find_domain(d->bus));
> +    snprintf(path, domain_len + 1, "%04x:00", pci_find_domain(d->bus));
> 
>      /* Fill in slot numbers. We walk up from device to root, so need to print
>       * them in the reverse order, last to first. */
>      p = path + path_len;
>      for (t = d; t; t = t->bus->parent_dev) {
>          p -= slot_len;
> -        snprintf(p, slot_len, ":%02x.%x", PCI_SLOT(t->devfn),
> PCI_FUNC(d->devfn));
> +        snprintf(p, slot_len + 1, ":%02x.%x", PCI_SLOT(t->devfn),
> PCI_FUNC(d->devfn));
>      }
> 
>      return path;
> -- 
> 1.7.3.1.msysgit.0

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-01-20 14:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-20 10:31 [Qemu-devel] [PATCH] pci: fix pcibus_get_dev_path() TeLeMan
2011-01-20 14:21 ` [Qemu-devel] " Michael S. Tsirkin

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).