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
This commit is contained in:
@@ -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
|
||||
|
Reference in New Issue
Block a user