summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThierry Vignaud <tv@mandriva.org>2009-12-01 14:40:47 +0000
committerThierry Vignaud <tv@mandriva.org>2009-12-01 14:40:47 +0000
commit67acd4010199817bc5bbd7f128caa073d3cd3e36 (patch)
tree67595bbd26d2a47a638f3c715ec5657389bbf1c0
parent2e95775d3c6e8bde22a5dbd9b8f78f7d55f18e9d (diff)
downloadldetect-67acd4010199817bc5bbd7f128caa073d3cd3e36.tar
ldetect-67acd4010199817bc5bbd7f128caa073d3cd3e36.tar.gz
ldetect-67acd4010199817bc5bbd7f128caa073d3cd3e36.tar.bz2
ldetect-67acd4010199817bc5bbd7f128caa073d3cd3e36.tar.xz
ldetect-67acd4010199817bc5bbd7f128caa073d3cd3e36.zip
(pci_probe) do not crash if there're more than 100 PCI devices
(usb_probe() was already safe)
-rw-r--r--NEWS1
-rw-r--r--pci.c2
2 files changed, 2 insertions, 1 deletions
diff --git a/NEWS b/NEWS
index 98c8417..43fa927 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,4 @@
+- do not crash if there're more than 100 PCI devices
- further use libpci in order to check for PCIe capability
Version 0.11.0 - 1 October 2009, Thierry Vignaud
diff --git a/pci.c b/pci.c
index 68c07af..5bd344f 100644
--- a/pci.c
+++ b/pci.c
@@ -51,7 +51,7 @@ extern struct pciusb_entries pci_probe(void) {
r.nb = 0;
r.entries = malloc(sizeof(struct pciusb_entry) * MAX_DEVICES);
- for (dev = pacc->devices; dev; dev = dev->next, r.nb++) {
+ for (dev = pacc->devices; dev && r.nb < MAX_DEVICES; dev = dev->next, r.nb++) {
struct pciusb_entry *e = &r.entries[r.nb];
memset(buf, 0, CONFIG_SPACE_SIZE); // make sure not to retrieve values from previous devices