MemoryAllocationLib: For boundary case: “AllocationSize + OverAllocationSize >= 4G”

DxeMemoryAllocationLib: Change the behavior from returning NULL to ASSERT ()
PeiMemoryAllocationLib: Add ASSERT ()
I also add ASSERT () in Pei Service AllocatePool () to catch if allocation size > 64K
DebugLib:
Header file (DebugLib.h): Fix an issue in ASSERT_PROTOCOL_ALREADY_INSTALLED(Handle, Guid).  
In contrast with LocateProtocol (), the first & second parameter type of HandleProtocol () is EFI_HANDLE & EFI_GUID respectively.
UefiLib: 
For UnicodeStringDisplayLength (CONST CHAR8 *String), return 0 if String is NULL.
BasePrintLib: 
Add missing “EFIAPI” to UnicodeValueToString() and AsciiValueToString() and move their definitions from PrintLibInternal.c to PrintLib.c.
Fix the comments error(Maximum Length TIME”)


git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@275 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
qhuang8
2006-05-25 10:13:26 +00:00
parent d05003bed6
commit a3657e3e7a
9 changed files with 74 additions and 45 deletions

View File

@@ -158,6 +158,10 @@ InternalAllocateAlignedPages (
return NULL;
}
//
// Make sure that Pages plus EFI_SIZE_TO_PAGES (Alignment) does not overflow.
//
ASSERT (Pages <= (MAX_ADDRESS - EFI_SIZE_TO_PAGES (Alignment)));
//
// We would rather waste some memory to save PEI code size.
//
Memory = InternalAllocatePages (MemoryType, Pages + EFI_SIZE_TO_PAGES (Alignment));
@@ -569,6 +573,10 @@ InternalAllocateAlignedPool (
} else {
AlignmentMask = Alignment - 1;
}
//
// Make sure that AllocationSize plus AlignmentMask does not overflow.
//
ASSERT (AllocationSize <= (MAX_ADDRESS - AlignmentMask));
RawAddress = InternalAllocatePool (PoolType, AllocationSize + AlignmentMask);
@@ -609,6 +617,11 @@ AllocateAlignedPool (
AlignmentMask = Alignment - 1;
}
//
// Make sure that AllocationSize plus AlignmentMask does not overflow.
//
ASSERT (AllocationSize <= (MAX_ADDRESS - AlignmentMask));
RawAddress = AllocatePool (AllocationSize + AlignmentMask);
AlignedAddress = ((UINTN) RawAddress + AlignmentMask) & ~AlignmentMask;