summaryrefslogtreecommitdiff
path: root/DuetPkg/PciRootBridgeNoEnumerationDxe/X64/PcatIo.c
diff options
context:
space:
mode:
authorrsun3 <rsun3@6f19259b-4bc3-4df7-8a09-765794883524>2012-03-14 03:17:17 +0000
committerrsun3 <rsun3@6f19259b-4bc3-4df7-8a09-765794883524>2012-03-14 03:17:17 +0000
commit94020bb40f12a9057aed2dfaa89ad35d644d704e (patch)
tree17364401360e35632a0c99ad26ba016bfe9174a8 /DuetPkg/PciRootBridgeNoEnumerationDxe/X64/PcatIo.c
parent8a44cd74ecdf3237f1fed27d7c73aeef4a10a53f (diff)
Improve robustness when scanning PCI Option ROM.
Signed-off-by: rsun3 Reviewed-by: geekboy15a git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13095 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'DuetPkg/PciRootBridgeNoEnumerationDxe/X64/PcatIo.c')
-rw-r--r--DuetPkg/PciRootBridgeNoEnumerationDxe/X64/PcatIo.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/DuetPkg/PciRootBridgeNoEnumerationDxe/X64/PcatIo.c b/DuetPkg/PciRootBridgeNoEnumerationDxe/X64/PcatIo.c
index 5320f560d9..1e4c218032 100644
--- a/DuetPkg/PciRootBridgeNoEnumerationDxe/X64/PcatIo.c
+++ b/DuetPkg/PciRootBridgeNoEnumerationDxe/X64/PcatIo.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2005 - 2006, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2005 - 2012, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -436,8 +436,10 @@ CheckForRom (
Pcir.ImageLength = 0;
- if (EfiRomHeader.Signature == 0xaa55) {
-
+ if (EfiRomHeader.Signature == PCI_EXPANSION_ROM_HEADER_SIGNATURE &&
+ EfiRomHeader.PcirOffset != 0 &&
+ (EfiRomHeader.PcirOffset & 3) == 0 &&
+ RomBarSize + EfiRomHeader.PcirOffset + sizeof (PCI_DATA_STRUCTURE) <= MaxRomSize) {
ZeroMem (&Pcir, sizeof(Pcir));
IoDev->Mem.Read (
IoDev,
@@ -447,6 +449,12 @@ CheckForRom (
&Pcir
);
+ if (Pcir.Signature != PCI_DATA_STRUCTURE_SIGNATURE) {
+ break;
+ }
+ if (RomBarSize + Pcir.ImageLength * 512 > MaxRomSize) {
+ break;
+ }
if ((Pcir.Indicator & 0x80) == 0x00) {
LastImage = FALSE;
}