summaryrefslogtreecommitdiff
path: root/MdeModulePkg/Universal
diff options
context:
space:
mode:
authorQiu Shumin <shumin.qiu@intel.com>2015-07-01 08:27:03 +0000
committershenshushi <shenshushi@Edk2>2015-07-01 08:27:03 +0000
commite85e284e25f09c222fc838e6b298a91268f0b3ec (patch)
tree188831528a9c5a533d8fe04f0a1e01ef8a667502 /MdeModulePkg/Universal
parentf5fc27424b7d7309658a0115c8c5384cff7f4dbd (diff)
downloadedk2-platforms-e85e284e25f09c222fc838e6b298a91268f0b3ec.tar.xz
MdeModulePkg/Universal/PCD: Use safe string functions to refine code.
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Qiu Shumin <shumin.qiu@intel.com> Reviewed-by: Star Zeng <star.zeng@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17786 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdeModulePkg/Universal')
-rw-r--r--MdeModulePkg/Universal/PCD/Dxe/Service.c8
-rw-r--r--MdeModulePkg/Universal/PCD/Pei/Service.c8
2 files changed, 10 insertions, 6 deletions
diff --git a/MdeModulePkg/Universal/PCD/Dxe/Service.c b/MdeModulePkg/Universal/PCD/Dxe/Service.c
index cf5f2444f6..eb1e1cef0b 100644
--- a/MdeModulePkg/Universal/PCD/Dxe/Service.c
+++ b/MdeModulePkg/Universal/PCD/Dxe/Service.c
@@ -142,6 +142,7 @@ GetPcdName (
{
PCD_DATABASE_INIT *Database;
UINT8 *StringTable;
+ UINTN NameSize;
PCD_NAME_INDEX *PcdNameIndex;
CHAR8 *TokenSpaceName;
CHAR8 *PcdName;
@@ -188,14 +189,15 @@ GetPcdName (
//
// Need to get the full PCD name.
//
- Name = AllocateZeroPool (AsciiStrSize (TokenSpaceName) + AsciiStrSize (PcdName));
+ NameSize = AsciiStrSize (TokenSpaceName) + AsciiStrSize (PcdName);
+ Name = AllocateZeroPool (NameSize);
ASSERT (Name != NULL);
//
// Catenate TokenSpaceCName and PcdCName with a '.' to form the full PCD name.
//
- AsciiStrCat (Name, TokenSpaceName);
+ AsciiStrCatS (Name, NameSize, TokenSpaceName);
Name[AsciiStrSize (TokenSpaceName) - sizeof (CHAR8)] = '.';
- AsciiStrCat (Name, PcdName);
+ AsciiStrCatS (Name, NameSize, PcdName);
}
return Name;
diff --git a/MdeModulePkg/Universal/PCD/Pei/Service.c b/MdeModulePkg/Universal/PCD/Pei/Service.c
index 83309a6f39..45ce01b1fa 100644
--- a/MdeModulePkg/Universal/PCD/Pei/Service.c
+++ b/MdeModulePkg/Universal/PCD/Pei/Service.c
@@ -107,6 +107,7 @@ GetPcdName (
)
{
UINT8 *StringTable;
+ UINTN NameSize;
PCD_NAME_INDEX *PcdNameIndex;
CHAR8 *TokenSpaceName;
CHAR8 *PcdName;
@@ -144,14 +145,15 @@ GetPcdName (
//
// Need to get the full PCD name.
//
- Name = AllocateZeroPool (AsciiStrSize (TokenSpaceName) + AsciiStrSize (PcdName));
+ NameSize = AsciiStrSize (TokenSpaceName) + AsciiStrSize (PcdName);
+ Name = AllocateZeroPool (NameSize);
ASSERT (Name != NULL);
//
// Catenate TokenSpaceCName and PcdCName with a '.' to form the full PCD name.
//
- AsciiStrCat (Name, TokenSpaceName);
+ AsciiStrCatS (Name, NameSize, TokenSpaceName);
Name[AsciiStrSize (TokenSpaceName) - sizeof (CHAR8)] = '.';
- AsciiStrCat (Name, PcdName);
+ AsciiStrCatS (Name, NameSize, PcdName);
}
return Name;