* [PATCH] xl: print BDF parse errors
@ 2010-05-27 19:17 Jeremy Fitzhardinge
0 siblings, 0 replies; only message in thread
From: Jeremy Fitzhardinge @ 2010-05-27 19:17 UTC (permalink / raw)
To: Xen-devel; +Cc: Vincent Hanquez, Ian Jackson, Stefano Stabellini
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@citrix.com>
diff -r 67dd34a9bb71 tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c Thu May 27 11:59:37 2010 -0700
+++ b/tools/libxl/xl_cmdimpl.c Thu May 27 12:17:34 2010 -0700
@@ -1519,7 +1519,10 @@
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 @@
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);
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2010-05-27 19:17 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-27 19:17 [PATCH] xl: print BDF parse errors Jeremy Fitzhardinge
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.