X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=DuetPkg%2FPciRootBridgeNoEnumerationDxe%2FIa32%2FPcatIo.c;fp=DuetPkg%2FPciRootBridgeNoEnumerationDxe%2FIa32%2FPcatIo.c;h=fbfc2fadef5c3e586a94353c205c959b6e6cfc38;hp=7395ce2d8b45c9ea3e2a0e87598740367ed5d9f6;hb=94020bb40f12a9057aed2dfaa89ad35d644d704e;hpb=8a44cd74ecdf3237f1fed27d7c73aeef4a10a53f diff --git a/DuetPkg/PciRootBridgeNoEnumerationDxe/Ia32/PcatIo.c b/DuetPkg/PciRootBridgeNoEnumerationDxe/Ia32/PcatIo.c index 7395ce2d8b..fbfc2fadef 100644 --- a/DuetPkg/PciRootBridgeNoEnumerationDxe/Ia32/PcatIo.c +++ b/DuetPkg/PciRootBridgeNoEnumerationDxe/Ia32/PcatIo.c @@ -1,6 +1,6 @@ /*++ -Copyright (c) 2005 - 2008, Intel Corporation. All rights reserved.
+Copyright (c) 2005 - 2012, Intel Corporation. All rights reserved.
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; }