summaryrefslogtreecommitdiff
path: root/MdePkg/Library
diff options
context:
space:
mode:
authormdkinney <mdkinney@6f19259b-4bc3-4df7-8a09-765794883524>2009-10-01 23:48:00 +0000
committermdkinney <mdkinney@6f19259b-4bc3-4df7-8a09-765794883524>2009-10-01 23:48:00 +0000
commit5cfafa075aa238fbe6de41f06d6d2b1d2cb41678 (patch)
tree7ea48593a46e961f96614ab7d54249c5b57b080c /MdePkg/Library
parent23565921e3f22c15aa1111b61df54c120043f952 (diff)
downloadedk2-5cfafa075aa238fbe6de41f06d6d2b1d2cb41678.zip
edk2-5cfafa075aa238fbe6de41f06d6d2b1d2cb41678.tar.gz
edk2-5cfafa075aa238fbe6de41f06d6d2b1d2cb41678.tar.bz2
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
Diffstat (limited to 'MdePkg/Library')
-rw-r--r--MdePkg/Library/BasePeCoffLib/BasePeCoff.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/MdePkg/Library/BasePeCoffLib/BasePeCoff.c b/MdePkg/Library/BasePeCoffLib/BasePeCoff.c
index 5be6e90..eeabbb2 100644
--- a/MdePkg/Library/BasePeCoffLib/BasePeCoff.c
+++ b/MdePkg/Library/BasePeCoffLib/BasePeCoff.c
@@ -926,6 +926,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
//
Base = PeCoffLoaderImageAddress (ImageContext, Section->VirtualAddress);
@@ -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 (