diff options
author | Jian J Wang <jian.j.wang@intel.com> | 2017-11-01 23:18:34 +0800 |
---|---|---|
committer | Star Zeng <star.zeng@intel.com> | 2017-11-08 17:13:03 +0800 |
commit | 469293f8ee406f2b0bad2cf3bbbc510b2a1364eb (patch) | |
tree | fb99a6f8e8f0dd2b6a9f9c6108cd51fb7e3fe952 /MdeModulePkg/Universal/HiiDatabaseDxe | |
parent | cc05c72ef84e03d43a0244b8639e8c08336af066 (diff) | |
download | edk2-469293f8ee406f2b0bad2cf3bbbc510b2a1364eb.tar.gz edk2-469293f8ee406f2b0bad2cf3bbbc510b2a1364eb.tar.bz2 edk2-469293f8ee406f2b0bad2cf3bbbc510b2a1364eb.zip |
MdeModulePkg: Fix misuses of AllocateCopyPool
AllocateCopyPool(AllocationSize, *Buffer) will copy "AllocationSize" bytes of
memory from old "Buffer" to new allocated one. If "AllocationSize" is bigger
than size of "Buffer", heap memory overflow occurs during copy.
One solution is to allocate pool first then copy the necessary bytes to new
memory. Another is using ReallocatePool instead if old buffer will be freed
on spot.
Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Bi Dandan <dandan.bi@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jian J Wang <jian.j.wang@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Bi Dandan <dandan.bi@intel.com>
Diffstat (limited to 'MdeModulePkg/Universal/HiiDatabaseDxe')
-rw-r--r-- | MdeModulePkg/Universal/HiiDatabaseDxe/ConfigKeywordHandler.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigKeywordHandler.c b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigKeywordHandler.c index 1b48c1cebe..5d5f17fb17 100644 --- a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigKeywordHandler.c +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigKeywordHandler.c @@ -2543,12 +2543,15 @@ MergeToMultiKeywordResp ( MultiKeywordRespLen = (StrLen (*MultiKeywordResp) + 1 + StrLen (*KeywordResp) + 1) * sizeof (CHAR16);
- StringPtr = AllocateCopyPool (MultiKeywordRespLen, *MultiKeywordResp);
+ StringPtr = ReallocatePool (
+ StrSize (*MultiKeywordResp),
+ MultiKeywordRespLen,
+ *MultiKeywordResp
+ );
if (StringPtr == NULL) {
return EFI_OUT_OF_RESOURCES;
}
-
- FreePool (*MultiKeywordResp);
+
*MultiKeywordResp = StringPtr;
StrCatS (StringPtr, MultiKeywordRespLen / sizeof (CHAR16), L"&");
|