Check to see if the section size of non-zero before failing a load operation due to a NULL base or end address

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9326 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
mdkinney 2009-10-01 23:48:00 +00:00
parent 23565921e3
commit 5cfafa075a
1 changed files with 10 additions and 10 deletions

View File

@ -925,6 +925,14 @@ PeCoffLoaderLoadImage (
//
Section = FirstSection;
for (Index = 0, MaxEnd = NULL; Index < NumberOfSections; Index++) {
//
// Read the section
//
Size = (UINTN) Section->Misc.VirtualSize;
if ((Size == 0) || (Size > Section->SizeOfRawData)) {
Size = (UINTN) Section->SizeOfRawData;
}
//
// Compute sections address
//
@ -935,9 +943,9 @@ PeCoffLoaderLoadImage (
);
//
// If the base start or end address resolved to 0, then fail.
// If the size of the section is non-zero and the base address or end address resolved to 0, then fail.
//
if ((Base == NULL) || (End == NULL)) {
if ((Size > 0) && ((Base == NULL) || (End == NULL))) {
ImageContext->ImageError = IMAGE_ERROR_SECTION_NOT_LOADED;
return RETURN_LOAD_ERROR;
}
@ -951,14 +959,6 @@ PeCoffLoaderLoadImage (
MaxEnd = End;
}
//
// Read the section
//
Size = (UINTN) Section->Misc.VirtualSize;
if ((Size == 0) || (Size > Section->SizeOfRawData)) {
Size = (UINTN) Section->SizeOfRawData;
}
if (Section->SizeOfRawData > 0) {
if (!(ImageContext->IsTeImage)) {
Status = ImageContext->ImageRead (