diff options
author | Zhichao Gao <zhichao.gao@intel.com> | 2019-07-15 14:23:21 +0800 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2019-12-05 06:12:36 +0000 |
commit | 94d4efb54ec4ca894287276ce22d29b6261dbc0b (patch) | |
tree | a18e017a9ab77dc75f96fa5022ba2ca9f7deb530 /ShellPkg | |
parent | 2926498f01e6d8b77dff933e3e9c87eb56c709b4 (diff) | |
download | edk2-94d4efb54ec4ca894287276ce22d29b6261dbc0b.tar.gz edk2-94d4efb54ec4ca894287276ce22d29b6261dbc0b.tar.bz2 edk2-94d4efb54ec4ca894287276ce22d29b6261dbc0b.zip |
ShellPkg/UefiHandleParsingLib: Fix error allocate pool
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1965
For function InsertNewGuidNameMapping, it rellocate the
mGuidList with new size
"mGuidListCount+1 * sizeof(GUID_INFO_BLOCK)". That isn't
its purpose and would cause a overflow operation in
"mGuidList[mGuidListCount - 1].xxx = xxx". Its purpose
is to increase 1 block size of mGuidList. Change it to
"(mGuidListCount + 1) * sizeof (GUID_INFO_BLOCK)".
Adjust the coding style of this function.
Cc: Jaben Carsey <jaben.carsey@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Andrew Fish <afish@apple.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Signed-off-by: Zhichao Gao <zhichao.gao@intel.com>
Diffstat (limited to 'ShellPkg')
-rw-r--r-- | ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c index f62d30ef67..500a95a89a 100644 --- a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c +++ b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c @@ -2462,17 +2462,21 @@ InsertNewGuidNameMapping( IN CONST DUMP_PROTOCOL_INFO DumpFunc OPTIONAL
)
{
- ASSERT(Guid != NULL);
- ASSERT(NameID != 0);
+ ASSERT (Guid != NULL);
+ ASSERT (NameID != 0);
- mGuidList = ReallocatePool(mGuidListCount * sizeof(GUID_INFO_BLOCK), mGuidListCount+1 * sizeof(GUID_INFO_BLOCK), mGuidList);
+ mGuidList = ReallocatePool (
+ mGuidListCount * sizeof (GUID_INFO_BLOCK),
+ (mGuidListCount + 1) * sizeof (GUID_INFO_BLOCK),
+ mGuidList
+ );
if (mGuidList == NULL) {
mGuidListCount = 0;
return (EFI_OUT_OF_RESOURCES);
}
mGuidListCount++;
- mGuidList[mGuidListCount - 1].GuidId = AllocateCopyPool(sizeof(EFI_GUID), Guid);
+ mGuidList[mGuidListCount - 1].GuidId = AllocateCopyPool (sizeof (EFI_GUID), Guid);
mGuidList[mGuidListCount - 1].StringId = NameID;
mGuidList[mGuidListCount - 1].DumpInfo = DumpFunc;
|