WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] xl: print BDF parse errors

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] xl: print BDF parse errors
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Sat, 29 May 2010 00:30:37 -0700
Delivery-date: Sat, 29 May 2010 00:33:59 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1275030735 -3600
# Node ID d86065bbb312cdf180a78ddecc7da18659ef6570
# Parent  5f6b780d09260c83a9a156bbd6c8abdefd5eb17c
xl: print BDF parse errors

When parsing BDFs for pci-attach/detach, check the return of scanf
rather than operating on random devices.

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@xxxxxxxxxx>
---
 tools/libxl/xl_cmdimpl.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diff -r 5f6b780d0926 -r d86065bbb312 tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c  Fri May 28 08:11:47 2010 +0100
+++ b/tools/libxl/xl_cmdimpl.c  Fri May 28 08:12:15 2010 +0100
@@ -1519,7 +1519,10 @@ void pcidetach(char *dom, char *bdf)
     find_domain(dom);
 
     memset(&pcidev, 0x00, sizeof(pcidev));
-    sscanf(bdf, PCI_BDF, &domain, &bus, &dev, &func);
+    if (sscanf(bdf, PCI_BDF, &domain, &bus, &dev, &func) != 4) {
+        fprintf(stderr, "pci-detach: malformed BDF specification \"%s\"\n", 
bdf);
+        exit(2);
+    }
     libxl_device_pci_init(&pcidev, domain, bus, dev, func, 0);
     libxl_device_pci_remove(&ctx, domid, &pcidev);
 }
@@ -1558,7 +1561,10 @@ void pciattach(char *dom, char *bdf, cha
     find_domain(dom);
 
     memset(&pcidev, 0x00, sizeof(pcidev));
-    sscanf(bdf, PCI_BDF, &domain, &bus, &dev, &func);
+    if (sscanf(bdf, PCI_BDF, &domain, &bus, &dev, &func) != 4) {
+        fprintf(stderr, "pci-attach: malformed BDF specification \"%s\"\n", 
bdf);
+        exit(2);
+    }
     libxl_device_pci_init(&pcidev, domain, bus, dev, func, 0);
     libxl_device_pci_add(&ctx, domid, &pcidev);
 }

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] xl: print BDF parse errors, Xen patchbot-unstable <=