mirror of
https://github.com/acidanthera/audk.git
synced 2025-07-25 22:54:51 +02:00
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:
parent
23565921e3
commit
5cfafa075a
@ -925,6 +925,14 @@ PeCoffLoaderLoadImage (
|
|||||||
//
|
//
|
||||||
Section = FirstSection;
|
Section = FirstSection;
|
||||||
for (Index = 0, MaxEnd = NULL; Index < NumberOfSections; Index++) {
|
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
|
// 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;
|
ImageContext->ImageError = IMAGE_ERROR_SECTION_NOT_LOADED;
|
||||||
return RETURN_LOAD_ERROR;
|
return RETURN_LOAD_ERROR;
|
||||||
}
|
}
|
||||||
@ -951,14 +959,6 @@ PeCoffLoaderLoadImage (
|
|||||||
MaxEnd = End;
|
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 (Section->SizeOfRawData > 0) {
|
||||||
if (!(ImageContext->IsTeImage)) {
|
if (!(ImageContext->IsTeImage)) {
|
||||||
Status = ImageContext->ImageRead (
|
Status = ImageContext->ImageRead (
|
||||||
|
Loading…
x
Reference in New Issue
Block a user