diff options
author | mdkinney <mdkinney@6f19259b-4bc3-4df7-8a09-765794883524> | 2006-09-19 18:53:32 +0000 |
---|---|---|
committer | mdkinney <mdkinney@6f19259b-4bc3-4df7-8a09-765794883524> | 2006-09-19 18:53:32 +0000 |
commit | 0e84e0d7bdb833343423ac68551d019e8788325a (patch) | |
tree | 45c7e3c72c05cdd0c38b07eb25eb3eb651938538 | |
parent | 202515b47d871f46fbd14ce1750a95e604763c5d (diff) | |
download | edk2-platforms-0e84e0d7bdb833343423ac68551d019e8788325a.tar.xz |
Fix buffer overflow when the raw size of a section and the virtual size of a section are not the same.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1564 6f19259b-4bc3-4df7-8a09-765794883524
-rw-r--r-- | Tools/Source/TianoTools/PeiRebase/PeiRebaseExe.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/Tools/Source/TianoTools/PeiRebase/PeiRebaseExe.c b/Tools/Source/TianoTools/PeiRebase/PeiRebaseExe.c index 27c646e486..35329c74d6 100644 --- a/Tools/Source/TianoTools/PeiRebase/PeiRebaseExe.c +++ b/Tools/Source/TianoTools/PeiRebase/PeiRebaseExe.c @@ -624,12 +624,12 @@ Returns: // Allocate a buffer for the image to be loaded into.
//
Pe32ImageSize = GetLength (CurrentPe32Section.Pe32Section->CommonHeader.Size) - sizeof (EFI_PE32_SECTION);
- MemoryImagePointer = (UINTN) (malloc (Pe32ImageSize + 0x1000));
+ MemoryImagePointer = (UINTN) (malloc (Pe32ImageSize + 0x1000 + ImageContext.SectionAlignment));
if (MemoryImagePointer == 0) {
Error (NULL, 0, 0, "memory allocation failure", NULL);
return EFI_OUT_OF_RESOURCES;
}
- memset ((void *) MemoryImagePointer, 0, Pe32ImageSize + 0x1000);
+ memset ((void *) MemoryImagePointer, 0, Pe32ImageSize + 0x1000 + ImageContext.SectionAlignment);
MemoryImagePointerAligned = (MemoryImagePointer + 0x0FFF) & (-1 << 12);
@@ -876,13 +876,13 @@ Returns: //
// Allocate a buffer for the image to be loaded into.
//
- MemoryImagePointer = (UINTN) (malloc (Pe32ImageSize + 0x1000));
+ MemoryImagePointer = (UINTN) (malloc (Pe32ImageSize + 0x1000 + ImageContext.SectionAlignment));
if (MemoryImagePointer == 0) {
Error (NULL, 0, 0, "memory allocation error on rebase of TE image", FileGuidString);
free (TEBuffer);
return EFI_OUT_OF_RESOURCES;
}
- memset ((void *) MemoryImagePointer, 0, Pe32ImageSize + 0x1000);
+ memset ((void *) MemoryImagePointer, 0, Pe32ImageSize + 0x1000 + ImageContext.SectionAlignment);
MemoryImagePointerAligned = (MemoryImagePointer + 0x0FFF) & (-1 << 12);
|