summaryrefslogtreecommitdiff
path: root/MdeModulePkg/Library/UefiHiiLib/HiiLib.c
diff options
context:
space:
mode:
authorDandan Bi <dandan.bi@intel.com>2015-06-29 02:36:31 +0000
committerdandanbi <dandanbi@Edk2>2015-06-29 02:36:31 +0000
commit5ad66ec6925f1564137752be4d8656d462ebeaf2 (patch)
tree62c65c37d412e3ab06e55fa209a2e4f013f9f576 /MdeModulePkg/Library/UefiHiiLib/HiiLib.c
parente9da7deaa475fee947760d49e46c74bae90449ad (diff)
downloadedk2-5ad66ec6925f1564137752be4d8656d462ebeaf2.zip
edk2-5ad66ec6925f1564137752be4d8656d462ebeaf2.tar.gz
edk2-5ad66ec6925f1564137752be4d8656d462ebeaf2.tar.bz2
MdeModulePkg:Use safe string functions
Replace unsafe String functions with new added safe string functions Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Dandan Bi <dandan.bi@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17724 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdeModulePkg/Library/UefiHiiLib/HiiLib.c')
-rw-r--r--MdeModulePkg/Library/UefiHiiLib/HiiLib.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/MdeModulePkg/Library/UefiHiiLib/HiiLib.c b/MdeModulePkg/Library/UefiHiiLib/HiiLib.c
index 7ae5c4c..bee5e0d 100644
--- a/MdeModulePkg/Library/UefiHiiLib/HiiLib.c
+++ b/MdeModulePkg/Library/UefiHiiLib/HiiLib.c
@@ -1,7 +1,7 @@
/** @file
HII Library implementation that uses DXE protocols and services.
- Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -606,6 +606,7 @@ HiiConstructConfigHdr (
CHAR16 *ReturnString;
UINTN Index;
UINT8 *Buffer;
+ UINTN MaxLen;
//
// Compute the length of Name in Unicode characters.
@@ -636,7 +637,8 @@ HiiConstructConfigHdr (
// GUID=<HexCh>32&NAME=<Char>NameLength&PATH=<HexChar>DevicePathSize <Null>
// | 5 | sizeof (EFI_GUID) * 2 | 6 | NameStrLen*4 | 6 | DevicePathSize * 2 | 1 |
//
- String = AllocateZeroPool ((5 + sizeof (EFI_GUID) * 2 + 6 + NameLength * 4 + 6 + DevicePathSize * 2 + 1) * sizeof (CHAR16));
+ MaxLen = 5 + sizeof (EFI_GUID) * 2 + 6 + NameLength * 4 + 6 + DevicePathSize * 2 + 1;
+ String = AllocateZeroPool (MaxLen * sizeof (CHAR16));
if (String == NULL) {
return NULL;
}
@@ -644,7 +646,8 @@ HiiConstructConfigHdr (
//
// Start with L"GUID="
//
- ReturnString = StrCpy (String, L"GUID=");
+ StrCpyS (String, MaxLen, L"GUID=");
+ ReturnString = String;
String += StrLen (String);
if (Guid != NULL) {
@@ -659,7 +662,7 @@ HiiConstructConfigHdr (
//
// Append L"&NAME="
//
- StrCpy (String, L"&NAME=");
+ StrCpyS (String, MaxLen, L"&NAME=");
String += StrLen (String);
if (Name != NULL) {
@@ -674,7 +677,7 @@ HiiConstructConfigHdr (
//
// Append L"&PATH="
//
- StrCpy (String, L"&PATH=");
+ StrCpyS (String, MaxLen, L"&PATH=");
String += StrLen (String);
//
@@ -786,7 +789,7 @@ InternalHiiGetBufferFromString (
StringPtr = (CHAR16 *) DataBuffer;
ZeroMem (TemStr, sizeof (TemStr));
for (Index = 0; Index < Length; Index += 4) {
- StrnCpy (TemStr, ConfigHdr + Index, 4);
+ StrnCpyS (TemStr, sizeof (TemStr) / sizeof (CHAR16), ConfigHdr + Index, 4);
StringPtr[Index/4] = (CHAR16) StrHexToUint64 (TemStr);
}
//
@@ -2011,6 +2014,7 @@ InternalHiiIfrValueAction (
EFI_HII_PACKAGE_LIST_HEADER *HiiPackageList;
UINTN PackageListLength;
+ UINTN MaxLen;
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
@@ -2266,14 +2270,15 @@ NextConfigAltResp:
// Construct ConfigAltHdr string "&<ConfigHdr>&ALTCFG=\0"
// | 1 | StrLen (ConfigHdr) | 8 | 1 |
//
- ConfigAltHdr = AllocateZeroPool ((1 + StringPtr - StringHdr + 8 + 1) * sizeof (CHAR16));
+ MaxLen = 1 + StringPtr - StringHdr + 8 + 1;
+ ConfigAltHdr = AllocateZeroPool ( MaxLen * sizeof (CHAR16));
if (ConfigAltHdr == NULL) {
Status = EFI_OUT_OF_RESOURCES;
goto Done;
}
- StrCpy (ConfigAltHdr, L"&");
- StrnCat (ConfigAltHdr, StringHdr, StringPtr - StringHdr);
- StrCat (ConfigAltHdr, L"&ALTCFG=");
+ StrCpyS (ConfigAltHdr, MaxLen, L"&");
+ StrnCatS (ConfigAltHdr, MaxLen, StringHdr, StringPtr - StringHdr);
+ StrCatS (ConfigAltHdr, MaxLen, L"&ALTCFG=");
//
// Skip all AltResp (AltConfigHdr ConfigBody) for the same ConfigHdr