From fefe985dc62c45859319818d09ac834eb60bf0c9 Mon Sep 17 00:00:00 2001 From: John Baldwin Date: Mon, 9 Sep 2002 18:24:35 +0000 Subject: [PATCH] Make sure a $PIR table header has a valid length before accepting the table as valid. Submitted by: Michal Mertl --- sys/amd64/pci/pci_cfgreg.c | 3 ++- sys/i386/pci/pci_cfgreg.c | 3 ++- sys/i386/pci/pci_pir.c | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/sys/amd64/pci/pci_cfgreg.c b/sys/amd64/pci/pci_cfgreg.c index 1562fd95382..0d943f36cbd 100644 --- a/sys/amd64/pci/pci_cfgreg.c +++ b/sys/amd64/pci/pci_cfgreg.c @@ -169,7 +169,8 @@ pci_cfgregopen(void) i < (pt->pt_header.ph_length); i++) { ck += cv[i]; } - if (ck == 0) { + if (ck == 0 && pt->pt_header.ph_length > + sizeof(struct PIR_header)) { pci_route_table = pt; pci_route_count = (pt->pt_header.ph_length - sizeof(struct PIR_header)) / diff --git a/sys/i386/pci/pci_cfgreg.c b/sys/i386/pci/pci_cfgreg.c index 1562fd95382..0d943f36cbd 100644 --- a/sys/i386/pci/pci_cfgreg.c +++ b/sys/i386/pci/pci_cfgreg.c @@ -169,7 +169,8 @@ pci_cfgregopen(void) i < (pt->pt_header.ph_length); i++) { ck += cv[i]; } - if (ck == 0) { + if (ck == 0 && pt->pt_header.ph_length > + sizeof(struct PIR_header)) { pci_route_table = pt; pci_route_count = (pt->pt_header.ph_length - sizeof(struct PIR_header)) / diff --git a/sys/i386/pci/pci_pir.c b/sys/i386/pci/pci_pir.c index 1562fd95382..0d943f36cbd 100644 --- a/sys/i386/pci/pci_pir.c +++ b/sys/i386/pci/pci_pir.c @@ -169,7 +169,8 @@ pci_cfgregopen(void) i < (pt->pt_header.ph_length); i++) { ck += cv[i]; } - if (ck == 0) { + if (ck == 0 && pt->pt_header.ph_length > + sizeof(struct PIR_header)) { pci_route_table = pt; pci_route_count = (pt->pt_header.ph_length - sizeof(struct PIR_header)) /