diff options
author | Dandan Bi <dandan.bi@intel.com> | 2015-06-29 02:36:31 +0000 |
---|---|---|
committer | dandanbi <dandanbi@Edk2> | 2015-06-29 02:36:31 +0000 |
commit | 5ad66ec6925f1564137752be4d8656d462ebeaf2 (patch) | |
tree | 62c65c37d412e3ab06e55fa209a2e4f013f9f576 /MdeModulePkg/Universal/DisplayEngineDxe/ProcessOptions.c | |
parent | e9da7deaa475fee947760d49e46c74bae90449ad (diff) | |
download | edk2-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/Universal/DisplayEngineDxe/ProcessOptions.c')
-rw-r--r-- | MdeModulePkg/Universal/DisplayEngineDxe/ProcessOptions.c | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/MdeModulePkg/Universal/DisplayEngineDxe/ProcessOptions.c b/MdeModulePkg/Universal/DisplayEngineDxe/ProcessOptions.c index 52dc5f2..f55fb2e 100644 --- a/MdeModulePkg/Universal/DisplayEngineDxe/ProcessOptions.c +++ b/MdeModulePkg/Universal/DisplayEngineDxe/ProcessOptions.c @@ -28,6 +28,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. VOID
NewStrCat (
IN OUT CHAR16 *Destination,
+ IN UINTN DestMax,
IN CHAR16 *Source
)
{
@@ -45,7 +46,7 @@ NewStrCat ( Destination[Length] = NARROW_CHAR;
Length++;
- StrCpy (Destination + Length, Source);
+ StrCpyS (Destination + Length, DestMax - Length, Source);
}
/**
@@ -957,6 +958,7 @@ ProcessOptions ( UINT8 ValueType;
EFI_IFR_ORDERED_LIST *OrderList;
BOOLEAN ValueInvalid;
+ UINTN MaxLen;
Status = EFI_SUCCESS;
@@ -999,7 +1001,8 @@ ProcessOptions ( // We now know how many strings we will have, so we can allocate the
// space required for the array or strings.
//
- *OptionString = AllocateZeroPool (OrderList->MaxContainers * BufferSize);
+ MaxLen = OrderList->MaxContainers * BufferSize / sizeof (CHAR16);
+ *OptionString = AllocateZeroPool (MaxLen * sizeof (CHAR16));
ASSERT (*OptionString);
HiiValue.Type = ValueType;
@@ -1057,14 +1060,14 @@ ProcessOptions ( }
Character[0] = LEFT_ONEOF_DELIMITER;
- NewStrCat (OptionString[0], Character);
+ NewStrCat (OptionString[0], MaxLen, Character);
StringPtr = GetToken (OneOfOption->OptionOpCode->Option, gFormData->HiiHandle);
ASSERT (StringPtr != NULL);
- NewStrCat (OptionString[0], StringPtr);
+ NewStrCat (OptionString[0], MaxLen, StringPtr);
Character[0] = RIGHT_ONEOF_DELIMITER;
- NewStrCat (OptionString[0], Character);
+ NewStrCat (OptionString[0], MaxLen, Character);
Character[0] = CHAR_CARRIAGE_RETURN;
- NewStrCat (OptionString[0], Character);
+ NewStrCat (OptionString[0], MaxLen, Character);
FreePool (StringPtr);
}
@@ -1092,14 +1095,14 @@ ProcessOptions ( // Not report error, just get the correct option string info.
//
Character[0] = LEFT_ONEOF_DELIMITER;
- NewStrCat (OptionString[0], Character);
+ NewStrCat (OptionString[0], MaxLen, Character);
StringPtr = GetToken (OneOfOption->OptionOpCode->Option, gFormData->HiiHandle);
ASSERT (StringPtr != NULL);
- NewStrCat (OptionString[0], StringPtr);
+ NewStrCat (OptionString[0], MaxLen, StringPtr);
Character[0] = RIGHT_ONEOF_DELIMITER;
- NewStrCat (OptionString[0], Character);
+ NewStrCat (OptionString[0], MaxLen, Character);
Character[0] = CHAR_CARRIAGE_RETURN;
- NewStrCat (OptionString[0], Character);
+ NewStrCat (OptionString[0], MaxLen, Character);
FreePool (StringPtr);
continue;
@@ -1151,6 +1154,7 @@ ProcessOptions ( //
Status = GetSelectionInputPopUp (MenuOption);
} else {
+ MaxLen = BufferSize / sizeof(CHAR16);
*OptionString = AllocateZeroPool (BufferSize);
ASSERT (*OptionString);
@@ -1204,12 +1208,12 @@ ProcessOptions ( }
Character[0] = LEFT_ONEOF_DELIMITER;
- NewStrCat (OptionString[0], Character);
+ NewStrCat (OptionString[0], MaxLen, Character);
StringPtr = GetToken (OneOfOption->OptionOpCode->Option, gFormData->HiiHandle);
ASSERT (StringPtr != NULL);
- NewStrCat (OptionString[0], StringPtr);
+ NewStrCat (OptionString[0], MaxLen, StringPtr);
Character[0] = RIGHT_ONEOF_DELIMITER;
- NewStrCat (OptionString[0], Character);
+ NewStrCat (OptionString[0], MaxLen, Character);
FreePool (StringPtr);
}
|