From 9f4048f7f8cd4b6bd5eee0f0c4bfd4eb6926a536 Mon Sep 17 00:00:00 2001 From: Hao Wu Date: Wed, 18 Jan 2017 10:31:02 +0800 Subject: MdeModulePkg: Replace [Ascii|Unicode]ValueToString It is the follow up of commits 51f0ceb..9e32e97 to replace AsciiValueToString/UnicodeValueToString with AsciiValueToStringS/UnicodeValueToStringS. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Hao Wu Reviewed-by: Star Zeng --- .../HiiDatabaseDxe/ConfigKeywordHandler.c | 29 ++++++++++++-- .../Universal/HiiDatabaseDxe/ConfigRouting.c | 45 +++++++++++++++++++--- 2 files changed, 65 insertions(+), 9 deletions(-) (limited to 'MdeModulePkg/Universal/HiiDatabaseDxe') diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigKeywordHandler.c b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigKeywordHandler.c index 8e23a51..1b48c1c 100644 --- a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigKeywordHandler.c +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigKeywordHandler.c @@ -1,7 +1,7 @@ /** @file Implementation of interfaces function for EFI_CONFIG_KEYWORD_HANDLER_PROTOCOL. -Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.
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 @@ -1763,7 +1763,14 @@ ConstructConfigHdr ( // Append Guid converted to 32 // for (Index = 0, Buffer = (UINT8 *)Guid; Index < sizeof (EFI_GUID); Index++) { - String += UnicodeValueToString (String, PREFIX_ZERO | RADIX_HEX, *(Buffer++), 2); + UnicodeValueToStringS ( + String, + MaxLen * sizeof (CHAR16) - ((UINTN)String - (UINTN)ReturnString), + PREFIX_ZERO | RADIX_HEX, + *(Buffer++), + 2 + ); + String += StrnLenS (String, MaxLen - ((UINTN)String - (UINTN)ReturnString) / sizeof (CHAR16)); } } @@ -1778,7 +1785,14 @@ ConstructConfigHdr ( // Append Name converted to NameLength // for (; *Name != L'\0'; Name++) { - String += UnicodeValueToString (String, PREFIX_ZERO | RADIX_HEX, *Name, 4); + UnicodeValueToStringS ( + String, + MaxLen * sizeof (CHAR16) - ((UINTN)String - (UINTN)ReturnString), + PREFIX_ZERO | RADIX_HEX, + *Name, + 4 + ); + String += StrnLenS (String, MaxLen - ((UINTN)String - (UINTN)ReturnString) / sizeof (CHAR16)); } } @@ -1792,7 +1806,14 @@ ConstructConfigHdr ( // Append the device path associated with DriverHandle converted to DevicePathSize // for (Index = 0, Buffer = (UINT8 *)DevicePath; Index < DevicePathSize; Index++) { - String += UnicodeValueToString (String, PREFIX_ZERO | RADIX_HEX, *(Buffer++), 2); + UnicodeValueToStringS ( + String, + MaxLen * sizeof (CHAR16) - ((UINTN)String - (UINTN)ReturnString), + PREFIX_ZERO | RADIX_HEX, + *(Buffer++), + 2 + ); + String += StrnLenS (String, MaxLen - ((UINTN)String - (UINTN)ReturnString) / sizeof (CHAR16)); } // diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c index ccf4b5a..c9ff1cf 100644 --- a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c @@ -264,7 +264,14 @@ GenerateSubStr ( // TemBuffer = ((UINT8 *) Buffer); for (Index = 0; Index < BufferLen; Index ++, TemBuffer ++) { - TemString += UnicodeValueToString (TemString, PREFIX_ZERO | RADIX_HEX, *TemBuffer, 2); + UnicodeValueToStringS ( + TemString, + sizeof (CHAR16) * (Length - StrnLenS (Str, Length)), + PREFIX_ZERO | RADIX_HEX, + *TemBuffer, + 2 + ); + TemString += StrnLenS (TemString, Length - StrnLenS (Str, Length)); } break; case 2: @@ -277,7 +284,14 @@ GenerateSubStr ( // Convert Unicode String to Config String, e.g. "ABCD" => "0041004200430044" // for (; *TemName != L'\0'; TemName++) { - TemString += UnicodeValueToString (TemString, PREFIX_ZERO | RADIX_HEX, *TemName, 4); + UnicodeValueToStringS ( + TemString, + sizeof (CHAR16) * (Length - StrnLenS (Str, Length)), + PREFIX_ZERO | RADIX_HEX, + *TemName, + 4 + ); + TemString += StrnLenS (TemString, Length - StrnLenS (Str, Length)); } break; case 3: @@ -286,7 +300,14 @@ GenerateSubStr ( // TemBuffer = ((UINT8 *) Buffer) + BufferLen - 1; for (Index = 0; Index < BufferLen; Index ++, TemBuffer --) { - TemString += UnicodeValueToString (TemString, PREFIX_ZERO | RADIX_HEX, *TemBuffer, 2); + UnicodeValueToStringS ( + TemString, + sizeof (CHAR16) * (Length - StrnLenS (Str, Length)), + PREFIX_ZERO | RADIX_HEX, + *TemBuffer, + 2 + ); + TemString += StrnLenS (TemString, Length - StrnLenS (Str, Length)); } break; default: @@ -3712,7 +3733,14 @@ GenerateAltConfigResp ( TmpBuffer = (UINT8 *) &(DefaultValueData->Value); } for (; Width > 0 && (TmpBuffer != NULL); Width--) { - StringPtr += UnicodeValueToString (StringPtr, PREFIX_ZERO | RADIX_HEX, TmpBuffer[Width - 1], 2); + UnicodeValueToStringS ( + StringPtr, + Length * sizeof (CHAR16) - ((UINTN)StringPtr - (UINTN)*DefaultAltCfgResp), + PREFIX_ZERO | RADIX_HEX, + TmpBuffer[Width - 1], + 2 + ); + StringPtr += StrnLenS (StringPtr, Length - ((UINTN)StringPtr - (UINTN)*DefaultAltCfgResp) / sizeof (CHAR16)); } if (DefaultString != NULL){ FreePool(DefaultString); @@ -5403,7 +5431,14 @@ HiiBlockToConfig ( TemString = ValueStr; TemBuffer = Value + Width - 1; for (Index = 0; Index < Width; Index ++, TemBuffer --) { - TemString += UnicodeValueToString (TemString, PREFIX_ZERO | RADIX_HEX, *TemBuffer, 2); + UnicodeValueToStringS ( + TemString, + Length * sizeof (CHAR16) - ((UINTN)TemString - (UINTN)ValueStr), + PREFIX_ZERO | RADIX_HEX, + *TemBuffer, + 2 + ); + TemString += StrnLenS (TemString, Length - ((UINTN)TemString - (UINTN)ValueStr) / sizeof (CHAR16)); } FreePool (Value); -- cgit v1.1