diff options
author | qhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524> | 2006-04-25 05:51:23 +0000 |
---|---|---|
committer | qhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524> | 2006-04-25 05:51:23 +0000 |
commit | abea19dbe10720a4ef4f9e688996d71a493cebe9 (patch) | |
tree | a27ccd6b591aa35c094d9f076975e146447dc1b2 /MdePkg/Library/DxeMemoryAllocationLib | |
parent | ee19dec64fba479016c168daa80bc61fbd395936 (diff) | |
download | edk2-platforms-abea19dbe10720a4ef4f9e688996d71a493cebe9.tar.xz |
PeiSmbusLib & DxeSmbusLib
Remove Arp Related interfaces
Change the return type of SmbusQuickWrite from “BOOLEAN” to “VOID”
Complete interface SmBusBlockProcessCall()
Make the PEC bit “bit 21” of SMBUS address. If data show that MSB helps to save code size in BaseSmbusLib, we may simply redefine it to be MAX_BIT.
UefiLib
Modify the interfaces in UefiNotTiano.c to sync with spec
MemoryAllocationLib
Add extra checking in “Aligned” Memory services to prevent “AllocationSize + OverAllocation” overflow in DxeMemoryAllocationLib.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@23 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdePkg/Library/DxeMemoryAllocationLib')
-rw-r--r-- | MdePkg/Library/DxeMemoryAllocationLib/MemoryAllocationLib.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/MdePkg/Library/DxeMemoryAllocationLib/MemoryAllocationLib.c b/MdePkg/Library/DxeMemoryAllocationLib/MemoryAllocationLib.c index a9bdf60aa1..ef643eed42 100644 --- a/MdePkg/Library/DxeMemoryAllocationLib/MemoryAllocationLib.c +++ b/MdePkg/Library/DxeMemoryAllocationLib/MemoryAllocationLib.c @@ -168,6 +168,13 @@ InternalAllocateAlignedPages ( //
AlignmentMask = Alignment - 1;
RealPages = Pages + EFI_SIZE_TO_PAGES (Alignment);
+ if (RealPages <= Pages) {
+ //
+ // This extra checking is to make sure that Pages plus EFI_SIZE_TO_PAGES (Alignment) does not overflow.
+ //
+ return NULL;
+ }
+
Status = gBS->AllocatePages (AllocateAnyPages, MemoryType, RealPages, &Memory);
if (EFI_ERROR (Status)) {
return NULL;
@@ -576,8 +583,8 @@ InternalAllocateAlignedPool ( UINTN AlignedAddress;
UINTN AlignmentMask;
UINTN OverAllocationSize;
+ UINTN RealAllocationSize;
VOID **FreePointer;
- EFI_STATUS Status;
//
// Alignment must be a power of two or zero.
@@ -593,8 +600,15 @@ InternalAllocateAlignedPool ( // Calculate the extra memory size, over-allocate memory pool and get the aligned memory address.
//
OverAllocationSize = sizeof (RawAddress) + AlignmentMask;
- Status = gBS->AllocatePool (PoolType, AllocationSize + OverAllocationSize, &RawAddress);
- if (EFI_ERROR (Status)) {
+ RealAllocationSize = AllocationSize + OverAllocationSize;
+ if (RealAllocationSize <= AllocationSize ) {
+ //
+ // This extra checking is to make sure that AllocationSize plus OverAllocationSize does not overflow.
+ //
+ return NULL;
+ }
+ RawAddress = InternalAllocatePool (PoolType, RealAllocationSize);
+ if (RawAddress == NULL) {
return NULL;
}
AlignedAddress = ((UINTN) RawAddress + OverAllocationSize) & ~AlignmentMask;
|