* [PATCH 0/7] Mark [Ascii|Unicode]ValueToString as deprecated
@ 2017-02-21 11:35 Hao Wu
2017-02-21 11:35 ` [PATCH 1/7] IntelFrameworkModulePkg: Replace [Ascii|Unicode]ValueToString Hao Wu
` (7 more replies)
0 siblings, 8 replies; 13+ messages in thread
From: Hao Wu @ 2017-02-21 11:35 UTC (permalink / raw)
To: edk2-devel; +Cc: Hao Wu, Jiewen Yao
This patch series cleans up the usage of the following 2 PrintLib APIs:
UnicodeValueToString & AsciiValueToString
and replaces them with:
UnicodeValueToStringS & AsciiValueToStringS
The series also marks [Ascii|Unicode]ValueToString with the macro
'DISABLE_NEW_DEPRECATED_INTERFACES', indicating they are deprecated.
Cc: Jiewen Yao <jiewen.yao@intel.com>
Hao Wu (7):
IntelFrameworkModulePkg: Replace [Ascii|Unicode]ValueToString
MdeModulePkg: Replace [Ascii|Unicode]ValueToString
Nt32Pkg: Replace [Ascii|Unicode]ValueToString
SignedCapsulePkg: Replace [Ascii|Unicode]ValueToString
MdeModulePkg/PrintDxe: Handle the deprecation of [A|U]ValueToString
MdeModulePkg/PrintLib: Add deprecated flag for APIs [A|U]ValueToString
MdePkg/BasePrintLib: Add deprecated flag for APIs [A|U]ValueToString
IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/UpdatePage.c | 12 ++-
IntelFrameworkModulePkg/Universal/BdsDxe/DeviceMngr/DeviceManager.c | 20 ++++-
IntelFrameworkModulePkg/Universal/BdsDxe/FrontPage.c | 15 +++-
IntelFrameworkModulePkg/Universal/BdsDxe/MemoryTest.c | 6 +-
MdeModulePkg/Application/UiApp/FrontPage.c | 15 +++-
MdeModulePkg/Library/BootMaintenanceManagerUiLib/UpdatePage.c | 12 ++-
MdeModulePkg/Library/DeviceManagerUiLib/DeviceManager.c | 20 ++++-
MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleReportLib.c | 10 ++-
MdeModulePkg/Library/DxeNetLib/DxeNetLib.c | 24 ++++-
MdeModulePkg/Library/DxePrintLibPrint2Protocol/PrintLib.c | 12 +++
MdeModulePkg/Library/UefiHiiLib/HiiLib.c | 29 +++++-
MdeModulePkg/Universal/CapsulePei/UefiCapsule.c | 18 +++-
MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleService.c | 10 ++-
MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c | 37 +++++---
MdeModulePkg/Universal/HiiDatabaseDxe/ConfigKeywordHandler.c | 29 +++++-
MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c | 47 ++++++++--
MdeModulePkg/Universal/Network/VlanConfigDxe/VlanConfigImpl.c | 14 ++-
MdeModulePkg/Universal/PrintDxe/Print.c | 92 +++++++++++++++++++-
MdeModulePkg/Universal/SetupBrowserDxe/Expression.c | 11 ++-
MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c | 4 +-
MdeModulePkg/Universal/SetupBrowserDxe/Setup.c | 38 ++++++--
MdePkg/Include/Library/PrintLib.h | 12 +++
MdePkg/Library/BasePrintLib/PrintLib.c | 12 +++
Nt32Pkg/Library/PlatformBootManagerLib/MemoryTest.c | 6 +-
SignedCapsulePkg/Universal/RecoveryModuleLoadPei/ParseConfigProfile.c | 10 ++-
SignedCapsulePkg/Universal/SystemFirmwareUpdate/ParseConfigProfile.c | 10 ++-
26 files changed, 443 insertions(+), 82 deletions(-)
--
1.9.5.msysgit.0
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 1/7] IntelFrameworkModulePkg: Replace [Ascii|Unicode]ValueToString
2017-02-21 11:35 [PATCH 0/7] Mark [Ascii|Unicode]ValueToString as deprecated Hao Wu
@ 2017-02-21 11:35 ` Hao Wu
2017-02-27 7:36 ` Fan, Jeff
2017-02-21 11:35 ` [PATCH 2/7] MdeModulePkg: " Hao Wu
` (6 subsequent siblings)
7 siblings, 1 reply; 13+ messages in thread
From: Hao Wu @ 2017-02-21 11:35 UTC (permalink / raw)
To: edk2-devel; +Cc: Hao Wu, Jiewen Yao, Jeff Fan
It is the follow up of commits 51f0ceb..9e32e97 to replace
AsciiValueToString/UnicodeValueToString with
AsciiValueToStringS/UnicodeValueToStringS.
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jeff Fan <jeff.fan@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
---
IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/UpdatePage.c | 12 +++++++++---
IntelFrameworkModulePkg/Universal/BdsDxe/DeviceMngr/DeviceManager.c | 20 +++++++++++++++++---
IntelFrameworkModulePkg/Universal/BdsDxe/FrontPage.c | 15 +++++++++++----
IntelFrameworkModulePkg/Universal/BdsDxe/MemoryTest.c | 6 +++---
4 files changed, 40 insertions(+), 13 deletions(-)
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/UpdatePage.c b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/UpdatePage.c
index a2e38d2..bdf2614 100644
--- a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/UpdatePage.c
+++ b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/UpdatePage.c
@@ -1,7 +1,7 @@
/** @file
Dynamically update the pages.
-Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2017, 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
@@ -844,11 +844,17 @@ UpdateConModePage (
//
// Build mode string Column x Row
//
- UnicodeValueToString (ModeString, 0, Col, 0);
+ UnicodeValueToStringS (ModeString, sizeof (ModeString), 0, Col, 0);
PStr = &ModeString[0];
StrCatS (PStr, ARRAY_SIZE (ModeString), L" x ");
PStr = PStr + StrLen (PStr);
- UnicodeValueToString (PStr , 0, Row, 0);
+ UnicodeValueToStringS (
+ PStr,
+ sizeof (ModeString) - ((UINTN)PStr - (UINTN)&ModeString[0]),
+ 0,
+ Row,
+ 0
+ );
ModeToken[Index] = HiiSetString (CallbackData->BmmHiiHandle, 0, ModeString, NULL);
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/DeviceMngr/DeviceManager.c b/IntelFrameworkModulePkg/Universal/BdsDxe/DeviceMngr/DeviceManager.c
index af2b18a..125c49d 100644
--- a/IntelFrameworkModulePkg/Universal/BdsDxe/DeviceMngr/DeviceManager.c
+++ b/IntelFrameworkModulePkg/Universal/BdsDxe/DeviceMngr/DeviceManager.c
@@ -1,7 +1,7 @@
/** @file
The platform device manager reference implementation
-Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2017, 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
@@ -388,7 +388,14 @@ GetMacAddressString(
//
HwAddress = &MacAddressNode->MacAddress.Addr[0];
for (Index = 0; Index < HwAddressSize; Index++) {
- String += UnicodeValueToString (String, PREFIX_ZERO | RADIX_HEX, *(HwAddress++), 2);
+ UnicodeValueToStringS (
+ String,
+ BufferLen - ((UINTN)String - (UINTN)*PBuffer),
+ PREFIX_ZERO | RADIX_HEX,
+ *(HwAddress++),
+ 2
+ );
+ String += StrnLenS (String, (BufferLen - ((UINTN)String - (UINTN)*PBuffer)) / sizeof (CHAR16));
if (Index < HwAddressSize - 1) {
*String++ = L':';
}
@@ -408,7 +415,14 @@ GetMacAddressString(
if (VlanId != 0) {
*String++ = L'\\';
- String += UnicodeValueToString (String, PREFIX_ZERO | RADIX_HEX, VlanId, 4);
+ UnicodeValueToStringS (
+ String,
+ BufferLen - ((UINTN)String - (UINTN)*PBuffer),
+ PREFIX_ZERO | RADIX_HEX,
+ VlanId,
+ 4
+ );
+ String += StrnLenS (String, (BufferLen - ((UINTN)String - (UINTN)*PBuffer)) / sizeof (CHAR16));
}
//
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/FrontPage.c b/IntelFrameworkModulePkg/Universal/BdsDxe/FrontPage.c
index c771974..ec91422 100644
--- a/IntelFrameworkModulePkg/Universal/BdsDxe/FrontPage.c
+++ b/IntelFrameworkModulePkg/Universal/BdsDxe/FrontPage.c
@@ -1,7 +1,7 @@
/** @file
FrontPage routines to handle the callbacks and browser calls
-Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2017, 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
@@ -629,9 +629,16 @@ ConvertProcessorToString (
StringBuffer = AllocateZeroPool (0x20);
ASSERT (StringBuffer != NULL);
- Index = UnicodeValueToString (StringBuffer, LEFT_JUSTIFY, FreqMhz / 1000, 3);
+ UnicodeValueToStringS (StringBuffer, 0x20, LEFT_JUSTIFY, FreqMhz / 1000, 3);
+ Index = StrnLenS (StringBuffer, 0x20 / sizeof (CHAR16));
StrCatS (StringBuffer, 0x20 / sizeof (CHAR16), L".");
- UnicodeValueToString (StringBuffer + Index + 1, PREFIX_ZERO, (FreqMhz % 1000) / 10, 2);
+ UnicodeValueToStringS (
+ StringBuffer + Index + 1,
+ 0x20 - sizeof (CHAR16) * (Index + 1),
+ PREFIX_ZERO,
+ (FreqMhz % 1000) / 10,
+ 2
+ );
StrCatS (StringBuffer, 0x20 / sizeof (CHAR16), L" GHz");
*String = (CHAR16 *) StringBuffer;
return ;
@@ -655,7 +662,7 @@ ConvertMemorySizeToString (
StringBuffer = AllocateZeroPool (0x20);
ASSERT (StringBuffer != NULL);
- UnicodeValueToString (StringBuffer, LEFT_JUSTIFY, MemorySize, 6);
+ UnicodeValueToStringS (StringBuffer, 0x20, LEFT_JUSTIFY, MemorySize, 6);
StrCatS (StringBuffer, 0x20 / sizeof (CHAR16), L" MB RAM");
*String = (CHAR16 *) StringBuffer;
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/MemoryTest.c b/IntelFrameworkModulePkg/Universal/BdsDxe/MemoryTest.c
index 700e3e6..1188082 100644
--- a/IntelFrameworkModulePkg/Universal/BdsDxe/MemoryTest.c
+++ b/IntelFrameworkModulePkg/Universal/BdsDxe/MemoryTest.c
@@ -1,7 +1,7 @@
/** @file
Perform the platform memory test
-Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2017, 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
@@ -318,7 +318,7 @@ BdsMemoryTest (
TempData
);
if (TestPercent != PreviousValue) {
- UnicodeValueToString (StrPercent, 0, TestPercent, 0);
+ UnicodeValueToStringS (StrPercent, sizeof (StrPercent), 0, TestPercent, 0);
TmpStr = GetStringById (STRING_TOKEN (STR_MEMORY_TEST_PERCENT));
if (TmpStr != NULL) {
//
@@ -386,7 +386,7 @@ BdsMemoryTest (
Done:
if (!FeaturePcdGet(PcdBootlogoOnlyEnable)) {
- UnicodeValueToString (StrTotalMemory, COMMA_TYPE, TotalMemorySize, 0);
+ UnicodeValueToStringS (StrTotalMemory, StrTotalMemorySize, COMMA_TYPE, TotalMemorySize, 0);
if (StrTotalMemory[0] == L',') {
StrTotalMemory++;
StrTotalMemorySize -= sizeof (CHAR16);
--
1.9.5.msysgit.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 2/7] MdeModulePkg: Replace [Ascii|Unicode]ValueToString
2017-02-21 11:35 [PATCH 0/7] Mark [Ascii|Unicode]ValueToString as deprecated Hao Wu
2017-02-21 11:35 ` [PATCH 1/7] IntelFrameworkModulePkg: Replace [Ascii|Unicode]ValueToString Hao Wu
@ 2017-02-21 11:35 ` Hao Wu
2017-02-28 8:13 ` Zeng, Star
2017-02-21 11:35 ` [PATCH 3/7] Nt32Pkg: " Hao Wu
` (5 subsequent siblings)
7 siblings, 1 reply; 13+ messages in thread
From: Hao Wu @ 2017-02-21 11:35 UTC (permalink / raw)
To: edk2-devel; +Cc: Hao Wu, Jiewen Yao, Feng Tian, Star Zeng
It is the follow up of commits 51f0ceb..9e32e97 to replace
AsciiValueToString/UnicodeValueToString with
AsciiValueToStringS/UnicodeValueToStringS.
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Feng Tian <feng.tian@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
---
MdeModulePkg/Application/UiApp/FrontPage.c | 15 +++++--
MdeModulePkg/Library/BootMaintenanceManagerUiLib/UpdatePage.c | 12 +++--
MdeModulePkg/Library/DeviceManagerUiLib/DeviceManager.c | 20 +++++++--
MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleReportLib.c | 10 ++++-
MdeModulePkg/Library/DxeNetLib/DxeNetLib.c | 24 ++++++++--
MdeModulePkg/Library/UefiHiiLib/HiiLib.c | 29 ++++++++++--
MdeModulePkg/Universal/CapsulePei/UefiCapsule.c | 18 ++++++--
MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleService.c | 10 ++++-
MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c | 37 +++++++++------
MdeModulePkg/Universal/HiiDatabaseDxe/ConfigKeywordHandler.c | 29 ++++++++++--
MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c | 47 +++++++++++++++++---
MdeModulePkg/Universal/Network/VlanConfigDxe/VlanConfigImpl.c | 14 ++++--
MdeModulePkg/Universal/SetupBrowserDxe/Expression.c | 11 ++++-
MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c | 4 +-
MdeModulePkg/Universal/SetupBrowserDxe/Setup.c | 38 +++++++++++++---
15 files changed, 258 insertions(+), 60 deletions(-)
diff --git a/MdeModulePkg/Application/UiApp/FrontPage.c b/MdeModulePkg/Application/UiApp/FrontPage.c
index bda5ff9..ad5af2c 100644
--- a/MdeModulePkg/Application/UiApp/FrontPage.c
+++ b/MdeModulePkg/Application/UiApp/FrontPage.c
@@ -1,7 +1,7 @@
/** @file
FrontPage routines to handle the callbacks and browser calls
-Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2017, 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
@@ -408,9 +408,16 @@ ConvertProcessorToString (
DestMax = 0x20 / sizeof (CHAR16);
StringBuffer = AllocateZeroPool (0x20);
ASSERT (StringBuffer != NULL);
- Index = UnicodeValueToString (StringBuffer, LEFT_JUSTIFY, FreqMhz / 1000, 3);
+ UnicodeValueToStringS (StringBuffer, sizeof (CHAR16) * DestMax, LEFT_JUSTIFY, FreqMhz / 1000, 3);
+ Index = StrnLenS (StringBuffer, DestMax);
StrCatS (StringBuffer, DestMax, L".");
- UnicodeValueToString (StringBuffer + Index + 1, PREFIX_ZERO, (FreqMhz % 1000) / 10, 2);
+ UnicodeValueToStringS (
+ StringBuffer + Index + 1,
+ sizeof (CHAR16) * (DestMax - (Index + 1)),
+ PREFIX_ZERO,
+ (FreqMhz % 1000) / 10,
+ 2
+ );
StrCatS (StringBuffer, DestMax, L" GHz");
*String = (CHAR16 *) StringBuffer;
return ;
@@ -434,7 +441,7 @@ ConvertMemorySizeToString (
StringBuffer = AllocateZeroPool (0x24);
ASSERT (StringBuffer != NULL);
- UnicodeValueToString (StringBuffer, LEFT_JUSTIFY, MemorySize, 10);
+ UnicodeValueToStringS (StringBuffer, 0x24, LEFT_JUSTIFY, MemorySize, 10);
StrCatS (StringBuffer, 0x24 / sizeof (CHAR16), L" MB RAM");
*String = (CHAR16 *) StringBuffer;
diff --git a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/UpdatePage.c b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/UpdatePage.c
index dede4b3..b3cc3c8 100644
--- a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/UpdatePage.c
+++ b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/UpdatePage.c
@@ -1,7 +1,7 @@
/** @file
Dynamically update the pages.
-Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2017, 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
@@ -734,11 +734,17 @@ UpdateConModePage (
//
// Build mode string Column x Row
//
- UnicodeValueToString (ModeString, 0, Col, 0);
+ UnicodeValueToStringS (ModeString, sizeof (ModeString), 0, Col, 0);
PStr = &ModeString[0];
StrnCatS (PStr, ARRAY_SIZE (ModeString), L" x ", StrLen(L" x ") + 1);
PStr = PStr + StrLen (PStr);
- UnicodeValueToString (PStr , 0, Row, 0);
+ UnicodeValueToStringS (
+ PStr,
+ sizeof (ModeString) - ((UINTN)PStr - (UINTN)&ModeString[0]),
+ 0,
+ Row,
+ 0
+ );
ModeToken[Index] = HiiSetString (CallbackData->BmmHiiHandle, 0, ModeString, NULL);
diff --git a/MdeModulePkg/Library/DeviceManagerUiLib/DeviceManager.c b/MdeModulePkg/Library/DeviceManagerUiLib/DeviceManager.c
index 0de4e3c..5098b70 100644
--- a/MdeModulePkg/Library/DeviceManagerUiLib/DeviceManager.c
+++ b/MdeModulePkg/Library/DeviceManagerUiLib/DeviceManager.c
@@ -1,7 +1,7 @@
/** @file
The device manager reference implementation
-Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2017, 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
@@ -148,7 +148,14 @@ GetMacAddressString(
//
HwAddress = &MacAddressNode->MacAddress.Addr[0];
for (Index = 0; Index < HwAddressSize; Index++) {
- String += UnicodeValueToString (String, PREFIX_ZERO | RADIX_HEX, *(HwAddress++), 2);
+ UnicodeValueToStringS (
+ String,
+ BufferLen - ((UINTN)String - (UINTN)*PBuffer),
+ PREFIX_ZERO | RADIX_HEX,
+ *(HwAddress++),
+ 2
+ );
+ String += StrnLenS (String, (BufferLen - ((UINTN)String - (UINTN)*PBuffer)) / sizeof (CHAR16));
if (Index < HwAddressSize - 1) {
*String++ = L':';
}
@@ -168,7 +175,14 @@ GetMacAddressString(
if (VlanId != 0) {
*String++ = L'\\';
- String += UnicodeValueToString (String, PREFIX_ZERO | RADIX_HEX, VlanId, 4);
+ UnicodeValueToStringS (
+ String,
+ BufferLen - ((UINTN)String - (UINTN)*PBuffer),
+ PREFIX_ZERO | RADIX_HEX,
+ VlanId,
+ 4
+ );
+ String += StrnLenS (String, (BufferLen - ((UINTN)String - (UINTN)*PBuffer)) / sizeof (CHAR16));
}
//
diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleReportLib.c b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleReportLib.c
index 3a9bb6e..fc0f869 100644
--- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleReportLib.c
+++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleReportLib.c
@@ -1,7 +1,7 @@
/** @file
DXE capsule report related function.
- Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2016 - 2017, 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
@@ -377,7 +377,13 @@ InitCapsuleUpdateVariable (
Index = 0;
while (TRUE) {
if (Index > 0) {
- UnicodeValueToString (TempVarName, 0, Index, 0);
+ UnicodeValueToStringS (
+ TempVarName,
+ sizeof (CapsuleVarName) - ((UINTN)TempVarName - (UINTN)CapsuleVarName),
+ 0,
+ Index,
+ 0
+ );
}
Status = gRT->SetVariable (
CapsuleVarName,
diff --git a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c
index 0a7117c..84e113d 100644
--- a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c
+++ b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c
@@ -1,7 +1,7 @@
/** @file
Network library.
-Copyright (c) 2005 - 2016, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2005 - 2017, Intel Corporation. All rights reserved.<BR>
(C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
@@ -2225,6 +2225,7 @@ NetLibGetMacString (
UINT16 VlanId;
CHAR16 *String;
UINTN Index;
+ UINTN BufferSize;
ASSERT (MacString != NULL);
@@ -2241,7 +2242,8 @@ NetLibGetMacString (
// If VLAN is configured, it will need extra 5 characters like "\0005".
// Plus one unicode character for the null-terminator.
//
- String = AllocateZeroPool ((2 * HwAddressSize + 5 + 1) * sizeof (CHAR16));
+ BufferSize = (2 * HwAddressSize + 5 + 1) * sizeof (CHAR16);
+ String = AllocateZeroPool (BufferSize);
if (String == NULL) {
return EFI_OUT_OF_RESOURCES;
}
@@ -2252,7 +2254,14 @@ NetLibGetMacString (
//
HwAddress = &MacAddress.Addr[0];
for (Index = 0; Index < HwAddressSize; Index++) {
- String += UnicodeValueToString (String, PREFIX_ZERO | RADIX_HEX, *(HwAddress++), 2);
+ UnicodeValueToStringS (
+ String,
+ BufferSize - ((UINTN)String - (UINTN)*MacString),
+ PREFIX_ZERO | RADIX_HEX,
+ *(HwAddress++),
+ 2
+ );
+ String += StrnLenS (String, (BufferSize - ((UINTN)String - (UINTN)*MacString)) / sizeof (CHAR16));
}
//
@@ -2261,7 +2270,14 @@ NetLibGetMacString (
VlanId = NetLibGetVlanId (ServiceHandle);
if (VlanId != 0) {
*String++ = L'\\';
- String += UnicodeValueToString (String, PREFIX_ZERO | RADIX_HEX, VlanId, 4);
+ UnicodeValueToStringS (
+ String,
+ BufferSize - ((UINTN)String - (UINTN)*MacString),
+ PREFIX_ZERO | RADIX_HEX,
+ VlanId,
+ 4
+ );
+ String += StrnLenS (String, (BufferSize - ((UINTN)String - (UINTN)*MacString)) / sizeof (CHAR16));
}
//
diff --git a/MdeModulePkg/Library/UefiHiiLib/HiiLib.c b/MdeModulePkg/Library/UefiHiiLib/HiiLib.c
index 8579501..b740d43 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 - 2016, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2006 - 2017, 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
@@ -776,7 +776,14 @@ HiiConstructConfigHdr (
// Append Guid converted to <HexCh>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));
}
}
@@ -791,7 +798,14 @@ HiiConstructConfigHdr (
// Append Name converted to <Char>NameLength
//
for (; *Name != L'\0'; Name++) {
- String += UnicodeValueToString (String, PREFIX_ZERO | RADIX_HEX, *Name, 4);
+ UnicodeValueToStringS (
+ String,
+ sizeof (CHAR16) * MaxLen - ((UINTN)String - (UINTN)ReturnString),
+ PREFIX_ZERO | RADIX_HEX,
+ *Name,
+ 4
+ );
+ String += StrnLenS (String, MaxLen - ((UINTN)String - (UINTN)ReturnString) / sizeof (CHAR16));
}
}
@@ -805,7 +819,14 @@ HiiConstructConfigHdr (
// Append the device path associated with DriverHandle converted to <HexChar>DevicePathSize
//
for (Index = 0, Buffer = (UINT8 *)DevicePath; Index < DevicePathSize; Index++) {
- String += UnicodeValueToString (String, PREFIX_ZERO | RADIX_HEX, *(Buffer++), 2);
+ UnicodeValueToStringS (
+ String,
+ sizeof (CHAR16) * MaxLen - ((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/CapsulePei/UefiCapsule.c b/MdeModulePkg/Universal/CapsulePei/UefiCapsule.c
index 9ac9d22..53fe13f 100644
--- a/MdeModulePkg/Universal/CapsulePei/UefiCapsule.c
+++ b/MdeModulePkg/Universal/CapsulePei/UefiCapsule.c
@@ -1,7 +1,7 @@
/** @file
Capsule update PEIM for UEFI2.0
-Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions
@@ -768,7 +768,13 @@ GetCapsuleDescriptors (
return EFI_SUCCESS;
}
} else {
- UnicodeValueToString (TempVarName, 0, Index, 0);
+ UnicodeValueToStringS (
+ TempVarName,
+ sizeof (CapsuleVarName) - ((UINTN)TempVarName - (UINTN)CapsuleVarName),
+ 0,
+ Index,
+ 0
+ );
Status = PPIVariableServices->GetVariable (
PPIVariableServices,
CapsuleVarName,
@@ -891,7 +897,13 @@ CapsuleCoalesce (
TempVarName = CapsuleVarName + StrLen (CapsuleVarName);
while (TRUE) {
if (Index > 0) {
- UnicodeValueToString (TempVarName, 0, Index, 0);
+ UnicodeValueToStringS (
+ TempVarName,
+ sizeof (CapsuleVarName) - ((UINTN)TempVarName - (UINTN)CapsuleVarName),
+ 0,
+ Index,
+ 0
+ );
}
Status = PPIVariableServices->GetVariable (
PPIVariableServices,
diff --git a/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleService.c b/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleService.c
index ed8820a..216798d 100644
--- a/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleService.c
+++ b/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleService.c
@@ -4,7 +4,7 @@
It installs the Capsule Architectural Protocol defined in PI1.0a to signify
the capsule runtime services are ready.
-Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2017, 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
@@ -205,7 +205,13 @@ UpdateCapsule (
StrCpyS (CapsuleVarName, sizeof(CapsuleVarName)/sizeof(CHAR16), EFI_CAPSULE_VARIABLE_NAME);
TempVarName = CapsuleVarName + StrLen (CapsuleVarName);
if (mTimes > 0) {
- UnicodeValueToString (TempVarName, 0, mTimes, 0);
+ UnicodeValueToStringS (
+ TempVarName,
+ sizeof (CapsuleVarName) - ((UINTN)TempVarName - (UINTN)CapsuleVarName),
+ 0,
+ mTimes,
+ 0
+ );
}
//
diff --git a/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c b/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c
index 67a40b7..f103b9c 100644
--- a/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c
+++ b/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c
@@ -725,12 +725,14 @@ ExtractConfig (
BackupChar = Value[ValueStrLen];
*Value++ = L'=';
- Value += UnicodeValueToString (
- Value,
- PREFIX_ZERO | RADIX_HEX,
- PrivateData->Configuration.NameValueVar0,
- sizeof (PrivateData->Configuration.NameValueVar0) * 2
- );
+ UnicodeValueToStringS (
+ Value,
+ BufferSize - ((UINTN)Value - (UINTN)*Results),
+ PREFIX_ZERO | RADIX_HEX,
+ PrivateData->Configuration.NameValueVar0,
+ sizeof (PrivateData->Configuration.NameValueVar0) * 2
+ );
+ Value += StrnLenS (Value, (BufferSize - ((UINTN)Value - (UINTN)*Results)) / sizeof (CHAR16));
*Value = BackupChar;
}
@@ -744,12 +746,14 @@ ExtractConfig (
BackupChar = Value[ValueStrLen];
*Value++ = L'=';
- Value += UnicodeValueToString (
- Value,
- PREFIX_ZERO | RADIX_HEX,
- PrivateData->Configuration.NameValueVar1,
- sizeof (PrivateData->Configuration.NameValueVar1) * 2
- );
+ UnicodeValueToStringS (
+ Value,
+ BufferSize - ((UINTN)Value - (UINTN)*Results),
+ PREFIX_ZERO | RADIX_HEX,
+ PrivateData->Configuration.NameValueVar1,
+ sizeof (PrivateData->Configuration.NameValueVar1) * 2
+ );
+ Value += StrnLenS (Value, (BufferSize - ((UINTN)Value - (UINTN)*Results)) / sizeof (CHAR16));
*Value = BackupChar;
}
@@ -767,7 +771,14 @@ ExtractConfig (
//
StrPointer = (CHAR16 *) PrivateData->Configuration.NameValueVar2;
for (; *StrPointer != L'\0'; StrPointer++) {
- Value += UnicodeValueToString (Value, PREFIX_ZERO | RADIX_HEX, *StrPointer, 4);
+ UnicodeValueToStringS (
+ Value,
+ BufferSize - ((UINTN)Value - (UINTN)*Results),
+ PREFIX_ZERO | RADIX_HEX,
+ *StrPointer,
+ 4
+ );
+ Value += StrnLenS (Value, (BufferSize - ((UINTN)Value - (UINTN)*Results)) / sizeof (CHAR16));
}
}
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.<BR>
+Copyright (c) 2015 - 2017, 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
@@ -1763,7 +1763,14 @@ ConstructConfigHdr (
// Append Guid converted to <HexCh>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 <Char>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 <HexChar>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 d547f42..eafc037 100644
--- a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c
+++ b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c
@@ -1,7 +1,7 @@
/** @file
Implementation of interfaces function for EFI_HII_CONFIG_ROUTING_PROTOCOL.
-Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2007 - 2017, 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
@@ -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:
@@ -3703,7 +3724,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);
@@ -5390,7 +5418,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);
diff --git a/MdeModulePkg/Universal/Network/VlanConfigDxe/VlanConfigImpl.c b/MdeModulePkg/Universal/Network/VlanConfigDxe/VlanConfigImpl.c
index 5e0fe42..f035706 100644
--- a/MdeModulePkg/Universal/Network/VlanConfigDxe/VlanConfigImpl.c
+++ b/MdeModulePkg/Universal/Network/VlanConfigDxe/VlanConfigImpl.c
@@ -1,7 +1,7 @@
/** @file
HII Config Access protocol implementation of VLAN configuration module.
-Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2009 - 2017, 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
@@ -417,14 +417,22 @@ VlanUpdateForm (
//
// Pad VlanId string up to 4 characters with space
//
- DigitalCount = UnicodeValueToString (VlanIdStr, 0, VlanData[Index].VlanId, 5);
+ UnicodeValueToStringS (VlanIdStr, sizeof (VlanIdStr), 0, VlanData[Index].VlanId, 5);
+ DigitalCount = StrnLenS (VlanIdStr, ARRAY_SIZE (VlanIdStr));
SetMem16 (String, (4 - DigitalCount) * sizeof (CHAR16), L' ');
StrCpyS (String + 4 - DigitalCount, (sizeof (VlanStr) /sizeof (CHAR16)) - 10 - (4 - DigitalCount), VlanIdStr);
String += 4;
StrCpyS (String, (sizeof (VlanStr) /sizeof (CHAR16)) - 10 - (4 - DigitalCount) - 4, L", Priority:");
String += 11;
- String += UnicodeValueToString (String, 0, VlanData[Index].Priority, 4);
+ UnicodeValueToStringS (
+ String,
+ sizeof (VlanStr) - ((UINTN)String - (UINTN)VlanStr),
+ 0,
+ VlanData[Index].Priority,
+ 4
+ );
+ String += StrnLenS (String, ARRAY_SIZE (VlanStr) - ((UINTN)String - (UINTN)VlanStr) / sizeof (CHAR16));
*String = 0;
StringId = HiiSetString (PrivateData->HiiHandle, 0, VlanStr, NULL);
diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Expression.c b/MdeModulePkg/Universal/SetupBrowserDxe/Expression.c
index ec4d285..901b35c 100644
--- a/MdeModulePkg/Universal/SetupBrowserDxe/Expression.c
+++ b/MdeModulePkg/Universal/SetupBrowserDxe/Expression.c
@@ -1,7 +1,7 @@
/** @file
Utility functions for expression evaluation.
-Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2007 - 2017, 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
@@ -3143,7 +3143,14 @@ EvaluateExpression (
TempBuffer = (UINT8 *) &Value->Value + OpCode->ValueWidth - 1;
StrPtr = NameValue;
for (Index = 0; Index < OpCode->ValueWidth; Index ++, TempBuffer --) {
- StrPtr += UnicodeValueToString (StrPtr, PREFIX_ZERO | RADIX_HEX, *TempBuffer, 2);
+ UnicodeValueToStringS (
+ StrPtr,
+ (OpCode->ValueWidth * 2 + 1) * sizeof (CHAR16) - ((UINTN)StrPtr - (UINTN)NameValue),
+ PREFIX_ZERO | RADIX_HEX,
+ *TempBuffer,
+ 2
+ );
+ StrPtr += StrnLenS (StrPtr, OpCode->ValueWidth * 2 + 1 - ((UINTN)StrPtr - (UINTN)NameValue) / sizeof (CHAR16));
}
Status = SetValueByName (OpCode->VarStorage, OpCode->ValueName, NameValue, GetSetValueWithEditBuffer, NULL);
FreePool (NameValue);
diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c b/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c
index 61ba0b5..6b3e5e0 100644
--- a/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c
+++ b/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c
@@ -1,7 +1,7 @@
/** @file
Parser for IFR binary encoding.
-Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2007 - 2017, 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
@@ -116,7 +116,7 @@ UpdateCheckBoxStringToken (
ASSERT (Statement != NULL);
ASSERT (Statement->Operand == EFI_IFR_NUMERIC_OP);
- UnicodeValueToString (Str, 0, Statement->VarStoreInfo.VarName, MAXIMUM_VALUE_CHARACTERS - 1);
+ UnicodeValueToStringS (Str, sizeof (Str), 0, Statement->VarStoreInfo.VarName, MAXIMUM_VALUE_CHARACTERS - 1);
Id = HiiSetString (FormSet->HiiHandle, 0, Str, NULL);
if (Id == 0) {
diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c
index 06e682a..83dc2b8 100644
--- a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c
+++ b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c
@@ -1,7 +1,7 @@
/** @file
Entry and initialization module for the browser.
-Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2007 - 2017, 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
@@ -1972,7 +1972,14 @@ SetQuestionValue (
TemName = (CHAR16 *) Src;
TemString = Value;
for (; *TemName != L'\0'; TemName++) {
- TemString += UnicodeValueToString (TemString, PREFIX_ZERO | RADIX_HEX, *TemName, 4);
+ UnicodeValueToStringS (
+ TemString,
+ BufferLen - ((UINTN)TemString - (UINTN)Value),
+ PREFIX_ZERO | RADIX_HEX,
+ *TemName,
+ 4
+ );
+ TemString += StrnLenS (TemString, (BufferLen - ((UINTN)TemString - (UINTN)Value)) / sizeof (CHAR16));
}
} else {
BufferLen = StorageWidth * 2 + 1;
@@ -1984,7 +1991,14 @@ SetQuestionValue (
TemBuffer = Src + StorageWidth - 1;
TemString = Value;
for (Index = 0; Index < StorageWidth; Index ++, TemBuffer --) {
- TemString += UnicodeValueToString (TemString, PREFIX_ZERO | RADIX_HEX, *TemBuffer, 2);
+ UnicodeValueToStringS (
+ TemString,
+ BufferLen * sizeof (CHAR16) - ((UINTN)TemString - (UINTN)Value),
+ PREFIX_ZERO | RADIX_HEX,
+ *TemBuffer,
+ 2
+ );
+ TemString += StrnLenS (TemString, BufferLen - ((UINTN)TemString - (UINTN)Value) / sizeof (CHAR16));
}
}
@@ -2034,7 +2048,14 @@ SetQuestionValue (
TemName = (CHAR16 *) Src;
TemString = Value;
for (; *TemName != L'\0'; TemName++) {
- TemString += UnicodeValueToString (TemString, PREFIX_ZERO | RADIX_HEX, *TemName, 4);
+ UnicodeValueToStringS (
+ TemString,
+ MaxLen * sizeof (CHAR16) - ((UINTN)TemString - (UINTN)ConfigResp),
+ PREFIX_ZERO | RADIX_HEX,
+ *TemName,
+ 4
+ );
+ TemString += StrnLenS (TemString, MaxLen - ((UINTN)TemString - (UINTN)ConfigResp) / sizeof (CHAR16));
}
} else {
//
@@ -2043,7 +2064,14 @@ SetQuestionValue (
TemBuffer = Src + StorageWidth - 1;
TemString = Value;
for (Index = 0; Index < StorageWidth; Index ++, TemBuffer --) {
- TemString += UnicodeValueToString (TemString, PREFIX_ZERO | RADIX_HEX, *TemBuffer, 2);
+ UnicodeValueToStringS (
+ TemString,
+ MaxLen * sizeof (CHAR16) - ((UINTN)TemString - (UINTN)ConfigResp),
+ PREFIX_ZERO | RADIX_HEX,
+ *TemBuffer,
+ 2
+ );
+ TemString += StrnLenS (TemString, MaxLen - ((UINTN)TemString - (UINTN)ConfigResp) / sizeof (CHAR16));
}
}
--
1.9.5.msysgit.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 3/7] Nt32Pkg: Replace [Ascii|Unicode]ValueToString
2017-02-21 11:35 [PATCH 0/7] Mark [Ascii|Unicode]ValueToString as deprecated Hao Wu
2017-02-21 11:35 ` [PATCH 1/7] IntelFrameworkModulePkg: Replace [Ascii|Unicode]ValueToString Hao Wu
2017-02-21 11:35 ` [PATCH 2/7] MdeModulePkg: " Hao Wu
@ 2017-02-21 11:35 ` Hao Wu
2017-02-22 1:57 ` Ni, Ruiyu
2017-02-21 11:35 ` [PATCH 4/7] SignedCapsulePkg: " Hao Wu
` (4 subsequent siblings)
7 siblings, 1 reply; 13+ messages in thread
From: Hao Wu @ 2017-02-21 11:35 UTC (permalink / raw)
To: edk2-devel; +Cc: Hao Wu, Jiewen Yao, Ruiyu Ni
It is the follow up of commits 51f0ceb..9e32e97 to replace
AsciiValueToString/UnicodeValueToString with
AsciiValueToStringS/UnicodeValueToStringS.
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
---
Nt32Pkg/Library/PlatformBootManagerLib/MemoryTest.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/Nt32Pkg/Library/PlatformBootManagerLib/MemoryTest.c b/Nt32Pkg/Library/PlatformBootManagerLib/MemoryTest.c
index 93ecc7d..53e9ff4 100644
--- a/Nt32Pkg/Library/PlatformBootManagerLib/MemoryTest.c
+++ b/Nt32Pkg/Library/PlatformBootManagerLib/MemoryTest.c
@@ -1,7 +1,7 @@
/** @file
Perform the platform memory test
-Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2017, 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
@@ -155,7 +155,7 @@ PlatformBootManagerMemoryTest (
TempData
);
if (TestPercent != PreviousValue) {
- UnicodeValueToString (StrPercent, 0, TestPercent, 0);
+ UnicodeValueToStringS (StrPercent, sizeof (StrPercent), 0, TestPercent, 0);
TmpStr = HiiGetString (gStringPackHandle, STRING_TOKEN (STR_MEMORY_TEST_PERCENT), NULL);
if (TmpStr != NULL) {
//
@@ -223,7 +223,7 @@ PlatformBootManagerMemoryTest (
Done:
if (!FeaturePcdGet(PcdBootlogoOnlyEnable)) {
- UnicodeValueToString (StrTotalMemory, COMMA_TYPE, TotalMemorySize, 0);
+ UnicodeValueToStringS (StrTotalMemory, StrTotalMemorySize, COMMA_TYPE, TotalMemorySize, 0);
if (StrTotalMemory[0] == L',') {
StrTotalMemory++;
StrTotalMemorySize -= sizeof (CHAR16);
--
1.9.5.msysgit.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 4/7] SignedCapsulePkg: Replace [Ascii|Unicode]ValueToString
2017-02-21 11:35 [PATCH 0/7] Mark [Ascii|Unicode]ValueToString as deprecated Hao Wu
` (2 preceding siblings ...)
2017-02-21 11:35 ` [PATCH 3/7] Nt32Pkg: " Hao Wu
@ 2017-02-21 11:35 ` Hao Wu
2017-02-27 1:09 ` Yao, Jiewen
2017-02-21 11:35 ` [PATCH 5/7] MdeModulePkg/PrintDxe: Handle the deprecation of [A|U]ValueToString Hao Wu
` (3 subsequent siblings)
7 siblings, 1 reply; 13+ messages in thread
From: Hao Wu @ 2017-02-21 11:35 UTC (permalink / raw)
To: edk2-devel; +Cc: Hao Wu, Jiewen Yao
It is the follow up of commits 51f0ceb..9e32e97 to replace
AsciiValueToString/UnicodeValueToString with
AsciiValueToStringS/UnicodeValueToStringS.
Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
---
SignedCapsulePkg/Universal/RecoveryModuleLoadPei/ParseConfigProfile.c | 10 ++++++++--
SignedCapsulePkg/Universal/SystemFirmwareUpdate/ParseConfigProfile.c | 10 ++++++++--
2 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/SignedCapsulePkg/Universal/RecoveryModuleLoadPei/ParseConfigProfile.c b/SignedCapsulePkg/Universal/RecoveryModuleLoadPei/ParseConfigProfile.c
index fef1daf..204fd53 100644
--- a/SignedCapsulePkg/Universal/RecoveryModuleLoadPei/ParseConfigProfile.c
+++ b/SignedCapsulePkg/Universal/RecoveryModuleLoadPei/ParseConfigProfile.c
@@ -2,7 +2,7 @@
Parse the INI configuration file and pass the information to the recovery driver
so that the driver can perform recovery accordingly.
- Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions
@@ -85,7 +85,13 @@ ParseRecoveryDataFile (
// Get the section name of each update
//
AsciiStrCpyS (Entry, MAX_LINE_LENGTH, "Recovery");
- AsciiValueToString(Entry + AsciiStrLen(Entry), 0, Index, 0);
+ AsciiValueToStringS (
+ Entry + AsciiStrnLenS (Entry, MAX_LINE_LENGTH),
+ MAX_LINE_LENGTH - AsciiStrnLenS (Entry, MAX_LINE_LENGTH),
+ 0,
+ Index,
+ 0
+ );
Status = GetStringFromDataFile(
Context,
"Head",
diff --git a/SignedCapsulePkg/Universal/SystemFirmwareUpdate/ParseConfigProfile.c b/SignedCapsulePkg/Universal/SystemFirmwareUpdate/ParseConfigProfile.c
index dcad762..67584c6 100644
--- a/SignedCapsulePkg/Universal/SystemFirmwareUpdate/ParseConfigProfile.c
+++ b/SignedCapsulePkg/Universal/SystemFirmwareUpdate/ParseConfigProfile.c
@@ -2,7 +2,7 @@
Parse the INI configuration file and pass the information to the update driver
so that the driver can perform update accordingly.
- Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions
@@ -86,7 +86,13 @@ ParseUpdateDataFile (
// Get the section name of each update
//
AsciiStrCpyS (Entry, MAX_LINE_LENGTH, "Update");
- AsciiValueToString(Entry + AsciiStrLen(Entry), 0, Index, 0);
+ AsciiValueToStringS (
+ Entry + AsciiStrnLenS (Entry, MAX_LINE_LENGTH),
+ MAX_LINE_LENGTH - AsciiStrnLenS (Entry, MAX_LINE_LENGTH),
+ 0,
+ Index,
+ 0
+ );
Status = GetStringFromDataFile(
Context,
"Head",
--
1.9.5.msysgit.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 5/7] MdeModulePkg/PrintDxe: Handle the deprecation of [A|U]ValueToString
2017-02-21 11:35 [PATCH 0/7] Mark [Ascii|Unicode]ValueToString as deprecated Hao Wu
` (3 preceding siblings ...)
2017-02-21 11:35 ` [PATCH 4/7] SignedCapsulePkg: " Hao Wu
@ 2017-02-21 11:35 ` Hao Wu
2017-02-21 11:35 ` [PATCH 6/7] MdeModulePkg/PrintLib: Add deprecated flag for APIs [A|U]ValueToString Hao Wu
` (2 subsequent siblings)
7 siblings, 0 replies; 13+ messages in thread
From: Hao Wu @ 2017-02-21 11:35 UTC (permalink / raw)
To: edk2-devel; +Cc: Hao Wu, Jiewen Yao, Liming Gao, Michael Kinney
To handle the deprecation of PrintLib APIs UnicodeValueToString and
AsciiValueToString by subsequent commits, the commit refines the logic for
the implemetation of the UnicodeValueToString and AsciiValueToString
services in EFI_PRINT2_PROTOCOL.
When the macro DISABLE_NEW_DEPRECATED_INTERFACES is defined (indicating
the deprecation of the PrintLib APIs), the above two services will ASSERT
and will return zero to reflect not being supported.
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Michael Kinney <michael.d.kinney@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
---
MdeModulePkg/Universal/PrintDxe/Print.c | 92 +++++++++++++++++++-
1 file changed, 90 insertions(+), 2 deletions(-)
diff --git a/MdeModulePkg/Universal/PrintDxe/Print.c b/MdeModulePkg/Universal/PrintDxe/Print.c
index 85bc724..8029836 100644
--- a/MdeModulePkg/Universal/PrintDxe/Print.c
+++ b/MdeModulePkg/Universal/PrintDxe/Print.c
@@ -20,6 +20,94 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Library/DebugLib.h>
#include <Library/UefiDriverEntryPoint.h>
+/**
+ Implementaion of the UnicodeValueToString service in EFI_PRINT2_PROTOCOL.
+
+ If the macro DISABLE_NEW_DEPRECATED_INTERFACES is defined, then ASSERT().
+
+ @param Buffer The pointer to the output buffer for the produced
+ Null-terminated Unicode string.
+ @param Flags The bitmask of flags that specify left justification, zero
+ pad, and commas.
+ @param Value The 64-bit signed value to convert to a string.
+ @param Width The maximum number of Unicode characters to place in Buffer,
+ not including the Null-terminator.
+
+ @return If the macro DISABLE_NEW_DEPRECATED_INTERFACES is defined, return 0.
+ Otherwise, return the number of Unicode characters in Buffer not
+ including the Null-terminator.
+
+**/
+UINTN
+EFIAPI
+PrintDxeUnicodeValueToString (
+ IN OUT CHAR16 *Buffer,
+ IN UINTN Flags,
+ IN INT64 Value,
+ IN UINTN Width
+ )
+{
+#ifdef DISABLE_NEW_DEPRECATED_INTERFACES
+ //
+ // If the macro DISABLE_NEW_DEPRECATED_INTERFACES is defined, then the
+ // PrintLib API UnicodeValueToString is already deprecated.
+ // In this case, ASSERT will be triggered and zero will be returned for the
+ // implementation of the UnicodeValueToString service in EFI_PRINT2_PROTOCOL
+ // to indicate that the service is no longer supported.
+ //
+ DEBUG ((DEBUG_ERROR, "PrintDxe: The UnicodeValueToString service in EFI_PRINT2_PROTOCOL is no longer supported for security reason.\n"));
+ DEBUG ((DEBUG_ERROR, "PrintDxe: Please consider using the UnicodeValueToStringS service in EFI_PRINT2S_PROTOCOL.\n"));
+ ASSERT (FALSE);
+ return 0;
+#else
+ return UnicodeValueToString (Buffer, Flags, Value, Width);
+#endif
+}
+
+/**
+ Implementaion of the AsciiValueToString service in EFI_PRINT2_PROTOCOL.
+
+ If the macro DISABLE_NEW_DEPRECATED_INTERFACES is defined, then ASSERT().
+
+ @param Buffer A pointer to the output buffer for the produced
+ Null-terminated ASCII string.
+ @param Flags The bitmask of flags that specify left justification, zero
+ pad, and commas.
+ @param Value The 64-bit signed value to convert to a string.
+ @param Width The maximum number of ASCII characters to place in Buffer,
+ not including the Null-terminator.
+
+ @return If the macro DISABLE_NEW_DEPRECATED_INTERFACES is defined, return 0.
+ Otherwise, return the number of ASCII characters in Buffer not
+ including the Null-terminator.
+
+**/
+UINTN
+EFIAPI
+PrintDxeAsciiValueToString (
+ OUT CHAR8 *Buffer,
+ IN UINTN Flags,
+ IN INT64 Value,
+ IN UINTN Width
+ )
+{
+#ifdef DISABLE_NEW_DEPRECATED_INTERFACES
+ //
+ // If the macro DISABLE_NEW_DEPRECATED_INTERFACES is defined, then the
+ // PrintLib API AsciiValueToString is already deprecated.
+ // In this case, ASSERT will be triggered and zero will be returned for the
+ // implementation of the AsciiValueToString service in EFI_PRINT2_PROTOCOL
+ // to indicate that the service is no longer supported.
+ //
+ DEBUG ((DEBUG_ERROR, "PrintDxe: The AsciiValueToString service in EFI_PRINT2_PROTOCOL is no longer supported for security reason.\n"));
+ DEBUG ((DEBUG_ERROR, "PrintDxe: Please consider using the AsciiValueToStringS service in EFI_PRINT2S_PROTOCOL.\n"));
+ ASSERT (FALSE);
+ return 0;
+#else
+ return AsciiValueToString (Buffer, Flags, Value, Width);
+#endif
+}
+
EFI_HANDLE mPrintThunkHandle = NULL;
CONST EFI_PRINT2_PROTOCOL mPrint2Protocol = {
@@ -27,12 +115,12 @@ CONST EFI_PRINT2_PROTOCOL mPrint2Protocol = {
UnicodeSPrint,
UnicodeBSPrintAsciiFormat,
UnicodeSPrintAsciiFormat,
- UnicodeValueToString,
+ PrintDxeUnicodeValueToString,
AsciiBSPrint,
AsciiSPrint,
AsciiBSPrintUnicodeFormat,
AsciiSPrintUnicodeFormat,
- AsciiValueToString
+ PrintDxeAsciiValueToString
};
CONST EFI_PRINT2S_PROTOCOL mPrint2SProtocol = {
--
1.9.5.msysgit.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 6/7] MdeModulePkg/PrintLib: Add deprecated flag for APIs [A|U]ValueToString
2017-02-21 11:35 [PATCH 0/7] Mark [Ascii|Unicode]ValueToString as deprecated Hao Wu
` (4 preceding siblings ...)
2017-02-21 11:35 ` [PATCH 5/7] MdeModulePkg/PrintDxe: Handle the deprecation of [A|U]ValueToString Hao Wu
@ 2017-02-21 11:35 ` Hao Wu
2017-02-21 11:35 ` [PATCH 7/7] MdePkg/BasePrintLib: " Hao Wu
2017-02-23 1:50 ` [PATCH 0/7] Mark [Ascii|Unicode]ValueToString as deprecated Gao, Liming
7 siblings, 0 replies; 13+ messages in thread
From: Hao Wu @ 2017-02-21 11:35 UTC (permalink / raw)
To: edk2-devel; +Cc: Hao Wu, Jiewen Yao, Liming Gao, Michael Kinney
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Michael Kinney <michael.d.kinney@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
---
MdeModulePkg/Library/DxePrintLibPrint2Protocol/PrintLib.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/MdeModulePkg/Library/DxePrintLibPrint2Protocol/PrintLib.c b/MdeModulePkg/Library/DxePrintLibPrint2Protocol/PrintLib.c
index 589d4db..434736f 100644
--- a/MdeModulePkg/Library/DxePrintLibPrint2Protocol/PrintLib.c
+++ b/MdeModulePkg/Library/DxePrintLibPrint2Protocol/PrintLib.c
@@ -598,7 +598,11 @@ UnicodeSPrintAsciiFormat (
return NumberOfPrinted;
}
+#ifndef DISABLE_NEW_DEPRECATED_INTERFACES
+
/**
+ [ATTENTION] This function is deprecated for security reason.
+
Converts a decimal value to a Null-terminated Unicode string.
Converts the decimal number specified by Value to a Null-terminated Unicode
@@ -665,6 +669,8 @@ UnicodeValueToString (
return StrnLenS (Buffer, BufferSize / sizeof (CHAR16));
}
+#endif
+
/**
Converts a decimal value to a Null-terminated Unicode string.
@@ -1071,7 +1077,11 @@ AsciiSPrintUnicodeFormat (
}
+#ifndef DISABLE_NEW_DEPRECATED_INTERFACES
+
/**
+ [ATTENTION] This function is deprecated for security reason.
+
Converts a decimal value to a Null-terminated ASCII string.
Converts the decimal number specified by Value to a Null-terminated ASCII string
@@ -1137,6 +1147,8 @@ AsciiValueToString (
return AsciiStrnLenS (Buffer, BufferSize / sizeof (CHAR8));
}
+#endif
+
/**
Converts a decimal value to a Null-terminated Ascii string.
--
1.9.5.msysgit.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 7/7] MdePkg/BasePrintLib: Add deprecated flag for APIs [A|U]ValueToString
2017-02-21 11:35 [PATCH 0/7] Mark [Ascii|Unicode]ValueToString as deprecated Hao Wu
` (5 preceding siblings ...)
2017-02-21 11:35 ` [PATCH 6/7] MdeModulePkg/PrintLib: Add deprecated flag for APIs [A|U]ValueToString Hao Wu
@ 2017-02-21 11:35 ` Hao Wu
2017-02-23 1:50 ` [PATCH 0/7] Mark [Ascii|Unicode]ValueToString as deprecated Gao, Liming
7 siblings, 0 replies; 13+ messages in thread
From: Hao Wu @ 2017-02-21 11:35 UTC (permalink / raw)
To: edk2-devel; +Cc: Hao Wu, Jiewen Yao, Liming Gao, Michael Kinney
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Michael Kinney <michael.d.kinney@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
---
MdePkg/Include/Library/PrintLib.h | 12 ++++++++++++
MdePkg/Library/BasePrintLib/PrintLib.c | 12 ++++++++++++
2 files changed, 24 insertions(+)
diff --git a/MdePkg/Include/Library/PrintLib.h b/MdePkg/Include/Library/PrintLib.h
index 8c11dab..9fe3609 100644
--- a/MdePkg/Include/Library/PrintLib.h
+++ b/MdePkg/Include/Library/PrintLib.h
@@ -491,7 +491,11 @@ UnicodeSPrintAsciiFormat (
...
);
+#ifndef DISABLE_NEW_DEPRECATED_INTERFACES
+
/**
+ [ATTENTION] This function is deprecated for security reason.
+
Converts a decimal value to a Null-terminated Unicode string.
Converts the decimal number specified by Value to a Null-terminated Unicode
@@ -541,6 +545,8 @@ UnicodeValueToString (
IN UINTN Width
);
+#endif
+
/**
Converts a decimal value to a Null-terminated Unicode string.
@@ -882,7 +888,11 @@ AsciiSPrintUnicodeFormat (
...
);
+#ifndef DISABLE_NEW_DEPRECATED_INTERFACES
+
/**
+ [ATTENTION] This function is deprecated for security reason.
+
Converts a decimal value to a Null-terminated ASCII string.
Converts the decimal number specified by Value to a Null-terminated ASCII string
@@ -931,6 +941,8 @@ AsciiValueToString (
IN UINTN Width
);
+#endif
+
/**
Converts a decimal value to a Null-terminated Ascii string.
diff --git a/MdePkg/Library/BasePrintLib/PrintLib.c b/MdePkg/Library/BasePrintLib/PrintLib.c
index 221b52e..7453e95 100644
--- a/MdePkg/Library/BasePrintLib/PrintLib.c
+++ b/MdePkg/Library/BasePrintLib/PrintLib.c
@@ -349,7 +349,11 @@ UnicodeSPrintAsciiFormat (
return NumberOfPrinted;
}
+#ifndef DISABLE_NEW_DEPRECATED_INTERFACES
+
/**
+ [ATTENTION] This function is deprecated for security reason.
+
Converts a decimal value to a Null-terminated Unicode string.
Converts the decimal number specified by Value to a Null-terminated Unicode
@@ -403,6 +407,8 @@ UnicodeValueToString (
return BasePrintLibConvertValueToString ((CHAR8 *)Buffer, Flags, Value, Width, 2);
}
+#endif
+
/**
Converts a decimal value to a Null-terminated Unicode string.
@@ -781,7 +787,11 @@ AsciiSPrintUnicodeFormat (
}
+#ifndef DISABLE_NEW_DEPRECATED_INTERFACES
+
/**
+ [ATTENTION] This function is deprecated for security reason.
+
Converts a decimal value to a Null-terminated ASCII string.
Converts the decimal number specified by Value to a Null-terminated ASCII string
@@ -833,6 +843,8 @@ AsciiValueToString (
return BasePrintLibConvertValueToString (Buffer, Flags, Value, Width, 1);
}
+#endif
+
/**
Converts a decimal value to a Null-terminated Ascii string.
--
1.9.5.msysgit.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH 3/7] Nt32Pkg: Replace [Ascii|Unicode]ValueToString
2017-02-21 11:35 ` [PATCH 3/7] Nt32Pkg: " Hao Wu
@ 2017-02-22 1:57 ` Ni, Ruiyu
0 siblings, 0 replies; 13+ messages in thread
From: Ni, Ruiyu @ 2017-02-22 1:57 UTC (permalink / raw)
To: Wu, Hao A, edk2-devel@lists.01.org; +Cc: Wu, Hao A, Yao, Jiewen
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
Thanks/Ray
> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Hao
> Wu
> Sent: Tuesday, February 21, 2017 7:36 PM
> To: edk2-devel@lists.01.org
> Cc: Wu, Hao A <hao.a.wu@intel.com>; Ni, Ruiyu <ruiyu.ni@intel.com>; Yao,
> Jiewen <jiewen.yao@intel.com>
> Subject: [edk2] [PATCH 3/7] Nt32Pkg: Replace [Ascii|Unicode]ValueToString
>
> It is the follow up of commits 51f0ceb..9e32e97 to replace
> AsciiValueToString/UnicodeValueToString with
> AsciiValueToStringS/UnicodeValueToStringS.
>
> Cc: Jiewen Yao <jiewen.yao@intel.com>
> Cc: Ruiyu Ni <ruiyu.ni@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Hao Wu <hao.a.wu@intel.com>
> ---
> Nt32Pkg/Library/PlatformBootManagerLib/MemoryTest.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/Nt32Pkg/Library/PlatformBootManagerLib/MemoryTest.c
> b/Nt32Pkg/Library/PlatformBootManagerLib/MemoryTest.c
> index 93ecc7d..53e9ff4 100644
> --- a/Nt32Pkg/Library/PlatformBootManagerLib/MemoryTest.c
> +++ b/Nt32Pkg/Library/PlatformBootManagerLib/MemoryTest.c
> @@ -1,7 +1,7 @@
> /** @file
> Perform the platform memory test
>
> -Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>
> +Copyright (c) 2004 - 2017, 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 @@ -155,7 +155,7 @@
> PlatformBootManagerMemoryTest (
> TempData
> );
> if (TestPercent != PreviousValue) {
> - UnicodeValueToString (StrPercent, 0, TestPercent, 0);
> + UnicodeValueToStringS (StrPercent, sizeof (StrPercent), 0,
> + TestPercent, 0);
> TmpStr = HiiGetString (gStringPackHandle, STRING_TOKEN
> (STR_MEMORY_TEST_PERCENT), NULL);
> if (TmpStr != NULL) {
> //
> @@ -223,7 +223,7 @@ PlatformBootManagerMemoryTest (
>
> Done:
> if (!FeaturePcdGet(PcdBootlogoOnlyEnable)) {
> - UnicodeValueToString (StrTotalMemory, COMMA_TYPE, TotalMemorySize,
> 0);
> + UnicodeValueToStringS (StrTotalMemory, StrTotalMemorySize,
> + COMMA_TYPE, TotalMemorySize, 0);
> if (StrTotalMemory[0] == L',') {
> StrTotalMemory++;
> StrTotalMemorySize -= sizeof (CHAR16);
> --
> 1.9.5.msysgit.0
>
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 0/7] Mark [Ascii|Unicode]ValueToString as deprecated
2017-02-21 11:35 [PATCH 0/7] Mark [Ascii|Unicode]ValueToString as deprecated Hao Wu
` (6 preceding siblings ...)
2017-02-21 11:35 ` [PATCH 7/7] MdePkg/BasePrintLib: " Hao Wu
@ 2017-02-23 1:50 ` Gao, Liming
7 siblings, 0 replies; 13+ messages in thread
From: Gao, Liming @ 2017-02-23 1:50 UTC (permalink / raw)
To: Wu, Hao A, edk2-devel@lists.01.org; +Cc: Wu, Hao A, Yao, Jiewen
The change in PrintLib and PrintDxe (Patch 5~7) are good to me.
Reviewed-by: Liming Gao <liming.gao@intel.com>
Thanks
Liming
-----Original Message-----
From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Hao Wu
Sent: Tuesday, February 21, 2017 7:35 PM
To: edk2-devel@lists.01.org
Cc: Wu, Hao A <hao.a.wu@intel.com>; Yao, Jiewen <jiewen.yao@intel.com>
Subject: [edk2] [PATCH 0/7] Mark [Ascii|Unicode]ValueToString as deprecated
This patch series cleans up the usage of the following 2 PrintLib APIs:
UnicodeValueToString & AsciiValueToString
and replaces them with:
UnicodeValueToStringS & AsciiValueToStringS
The series also marks [Ascii|Unicode]ValueToString with the macro
'DISABLE_NEW_DEPRECATED_INTERFACES', indicating they are deprecated.
Cc: Jiewen Yao <jiewen.yao@intel.com>
Hao Wu (7):
IntelFrameworkModulePkg: Replace [Ascii|Unicode]ValueToString
MdeModulePkg: Replace [Ascii|Unicode]ValueToString
Nt32Pkg: Replace [Ascii|Unicode]ValueToString
SignedCapsulePkg: Replace [Ascii|Unicode]ValueToString
MdeModulePkg/PrintDxe: Handle the deprecation of [A|U]ValueToString
MdeModulePkg/PrintLib: Add deprecated flag for APIs [A|U]ValueToString
MdePkg/BasePrintLib: Add deprecated flag for APIs [A|U]ValueToString
IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/UpdatePage.c | 12 ++-
IntelFrameworkModulePkg/Universal/BdsDxe/DeviceMngr/DeviceManager.c | 20 ++++-
IntelFrameworkModulePkg/Universal/BdsDxe/FrontPage.c | 15 +++-
IntelFrameworkModulePkg/Universal/BdsDxe/MemoryTest.c | 6 +-
MdeModulePkg/Application/UiApp/FrontPage.c | 15 +++-
MdeModulePkg/Library/BootMaintenanceManagerUiLib/UpdatePage.c | 12 ++-
MdeModulePkg/Library/DeviceManagerUiLib/DeviceManager.c | 20 ++++-
MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleReportLib.c | 10 ++-
MdeModulePkg/Library/DxeNetLib/DxeNetLib.c | 24 ++++-
MdeModulePkg/Library/DxePrintLibPrint2Protocol/PrintLib.c | 12 +++
MdeModulePkg/Library/UefiHiiLib/HiiLib.c | 29 +++++-
MdeModulePkg/Universal/CapsulePei/UefiCapsule.c | 18 +++-
MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleService.c | 10 ++-
MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c | 37 +++++---
MdeModulePkg/Universal/HiiDatabaseDxe/ConfigKeywordHandler.c | 29 +++++-
MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c | 47 ++++++++--
MdeModulePkg/Universal/Network/VlanConfigDxe/VlanConfigImpl.c | 14 ++-
MdeModulePkg/Universal/PrintDxe/Print.c | 92 +++++++++++++++++++-
MdeModulePkg/Universal/SetupBrowserDxe/Expression.c | 11 ++-
MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c | 4 +-
MdeModulePkg/Universal/SetupBrowserDxe/Setup.c | 38 ++++++--
MdePkg/Include/Library/PrintLib.h | 12 +++
MdePkg/Library/BasePrintLib/PrintLib.c | 12 +++
Nt32Pkg/Library/PlatformBootManagerLib/MemoryTest.c | 6 +-
SignedCapsulePkg/Universal/RecoveryModuleLoadPei/ParseConfigProfile.c | 10 ++-
SignedCapsulePkg/Universal/SystemFirmwareUpdate/ParseConfigProfile.c | 10 ++-
26 files changed, 443 insertions(+), 82 deletions(-)
--
1.9.5.msysgit.0
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 4/7] SignedCapsulePkg: Replace [Ascii|Unicode]ValueToString
2017-02-21 11:35 ` [PATCH 4/7] SignedCapsulePkg: " Hao Wu
@ 2017-02-27 1:09 ` Yao, Jiewen
0 siblings, 0 replies; 13+ messages in thread
From: Yao, Jiewen @ 2017-02-27 1:09 UTC (permalink / raw)
To: Wu, Hao A, edk2-devel@lists.01.org
Reviewed-by: Jiewen.yao@intel.com
> -----Original Message-----
> From: Wu, Hao A
> Sent: Tuesday, February 21, 2017 7:36 PM
> To: edk2-devel@lists.01.org
> Cc: Wu, Hao A <hao.a.wu@intel.com>; Yao, Jiewen <jiewen.yao@intel.com>
> Subject: [PATCH 4/7] SignedCapsulePkg: Replace [Ascii|Unicode]ValueToString
>
> It is the follow up of commits 51f0ceb..9e32e97 to replace
> AsciiValueToString/UnicodeValueToString with
> AsciiValueToStringS/UnicodeValueToStringS.
>
> Cc: Jiewen Yao <jiewen.yao@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Hao Wu <hao.a.wu@intel.com>
> ---
> SignedCapsulePkg/Universal/RecoveryModuleLoadPei/ParseConfigProfile.c |
> 10 ++++++++--
> SignedCapsulePkg/Universal/SystemFirmwareUpdate/ParseConfigProfile.c |
> 10 ++++++++--
> 2 files changed, 16 insertions(+), 4 deletions(-)
>
> diff --git
> a/SignedCapsulePkg/Universal/RecoveryModuleLoadPei/ParseConfigProfile.c
> b/SignedCapsulePkg/Universal/RecoveryModuleLoadPei/ParseConfigProfile.c
> index fef1daf..204fd53 100644
> --- a/SignedCapsulePkg/Universal/RecoveryModuleLoadPei/ParseConfigProfile.c
> +++
> b/SignedCapsulePkg/Universal/RecoveryModuleLoadPei/ParseConfigProfile.c
> @@ -2,7 +2,7 @@
> Parse the INI configuration file and pass the information to the recovery
> driver
> so that the driver can perform recovery accordingly.
>
> - Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
> + Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.<BR>
>
> This program and the accompanying materials
> are licensed and made available under the terms and conditions
> @@ -85,7 +85,13 @@ ParseRecoveryDataFile (
> // Get the section name of each update
> //
> AsciiStrCpyS (Entry, MAX_LINE_LENGTH, "Recovery");
> - AsciiValueToString(Entry + AsciiStrLen(Entry), 0, Index, 0);
> + AsciiValueToStringS (
> + Entry + AsciiStrnLenS (Entry, MAX_LINE_LENGTH),
> + MAX_LINE_LENGTH - AsciiStrnLenS (Entry, MAX_LINE_LENGTH),
> + 0,
> + Index,
> + 0
> + );
> Status = GetStringFromDataFile(
> Context,
> "Head",
> diff --git
> a/SignedCapsulePkg/Universal/SystemFirmwareUpdate/ParseConfigProfile.c
> b/SignedCapsulePkg/Universal/SystemFirmwareUpdate/ParseConfigProfile.c
> index dcad762..67584c6 100644
> --- a/SignedCapsulePkg/Universal/SystemFirmwareUpdate/ParseConfigProfile.c
> +++
> b/SignedCapsulePkg/Universal/SystemFirmwareUpdate/ParseConfigProfile.c
> @@ -2,7 +2,7 @@
> Parse the INI configuration file and pass the information to the update driver
> so that the driver can perform update accordingly.
>
> - Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
> + Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.<BR>
>
> This program and the accompanying materials
> are licensed and made available under the terms and conditions
> @@ -86,7 +86,13 @@ ParseUpdateDataFile (
> // Get the section name of each update
> //
> AsciiStrCpyS (Entry, MAX_LINE_LENGTH, "Update");
> - AsciiValueToString(Entry + AsciiStrLen(Entry), 0, Index, 0);
> + AsciiValueToStringS (
> + Entry + AsciiStrnLenS (Entry, MAX_LINE_LENGTH),
> + MAX_LINE_LENGTH - AsciiStrnLenS (Entry, MAX_LINE_LENGTH),
> + 0,
> + Index,
> + 0
> + );
> Status = GetStringFromDataFile(
> Context,
> "Head",
> --
> 1.9.5.msysgit.0
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 1/7] IntelFrameworkModulePkg: Replace [Ascii|Unicode]ValueToString
2017-02-21 11:35 ` [PATCH 1/7] IntelFrameworkModulePkg: Replace [Ascii|Unicode]ValueToString Hao Wu
@ 2017-02-27 7:36 ` Fan, Jeff
0 siblings, 0 replies; 13+ messages in thread
From: Fan, Jeff @ 2017-02-27 7:36 UTC (permalink / raw)
To: Wu, Hao A, edk2-devel@lists.01.org; +Cc: Yao, Jiewen
Reviewed-by: Jeff Fan <jeff.fan@intel.com>
-----Original Message-----
From: Wu, Hao A
Sent: Tuesday, February 21, 2017 7:35 PM
To: edk2-devel@lists.01.org
Cc: Wu, Hao A; Yao, Jiewen; Fan, Jeff
Subject: [PATCH 1/7] IntelFrameworkModulePkg: Replace [Ascii|Unicode]ValueToString
It is the follow up of commits 51f0ceb..9e32e97 to replace AsciiValueToString/UnicodeValueToString with AsciiValueToStringS/UnicodeValueToStringS.
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jeff Fan <jeff.fan@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
---
IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/UpdatePage.c | 12 +++++++++---
IntelFrameworkModulePkg/Universal/BdsDxe/DeviceMngr/DeviceManager.c | 20 +++++++++++++++++---
IntelFrameworkModulePkg/Universal/BdsDxe/FrontPage.c | 15 +++++++++++----
IntelFrameworkModulePkg/Universal/BdsDxe/MemoryTest.c | 6 +++---
4 files changed, 40 insertions(+), 13 deletions(-)
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/UpdatePage.c b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/UpdatePage.c
index a2e38d2..bdf2614 100644
--- a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/UpdatePage.c
+++ b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/UpdatePage.c
@@ -1,7 +1,7 @@
/** @file
Dynamically update the pages.
-Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2017, 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 @@ -844,11 +844,17 @@ UpdateConModePage (
//
// Build mode string Column x Row
//
- UnicodeValueToString (ModeString, 0, Col, 0);
+ UnicodeValueToStringS (ModeString, sizeof (ModeString), 0, Col, 0);
PStr = &ModeString[0];
StrCatS (PStr, ARRAY_SIZE (ModeString), L" x ");
PStr = PStr + StrLen (PStr);
- UnicodeValueToString (PStr , 0, Row, 0);
+ UnicodeValueToStringS (
+ PStr,
+ sizeof (ModeString) - ((UINTN)PStr - (UINTN)&ModeString[0]),
+ 0,
+ Row,
+ 0
+ );
ModeToken[Index] = HiiSetString (CallbackData->BmmHiiHandle, 0, ModeString, NULL);
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/DeviceMngr/DeviceManager.c b/IntelFrameworkModulePkg/Universal/BdsDxe/DeviceMngr/DeviceManager.c
index af2b18a..125c49d 100644
--- a/IntelFrameworkModulePkg/Universal/BdsDxe/DeviceMngr/DeviceManager.c
+++ b/IntelFrameworkModulePkg/Universal/BdsDxe/DeviceMngr/DeviceManager.
+++ c
@@ -1,7 +1,7 @@
/** @file
The platform device manager reference implementation
-Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2017, 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 @@ -388,7 +388,14 @@ GetMacAddressString(
//
HwAddress = &MacAddressNode->MacAddress.Addr[0];
for (Index = 0; Index < HwAddressSize; Index++) {
- String += UnicodeValueToString (String, PREFIX_ZERO | RADIX_HEX, *(HwAddress++), 2);
+ UnicodeValueToStringS (
+ String,
+ BufferLen - ((UINTN)String - (UINTN)*PBuffer),
+ PREFIX_ZERO | RADIX_HEX,
+ *(HwAddress++),
+ 2
+ );
+ String += StrnLenS (String, (BufferLen - ((UINTN)String -
+ (UINTN)*PBuffer)) / sizeof (CHAR16));
if (Index < HwAddressSize - 1) {
*String++ = L':';
}
@@ -408,7 +415,14 @@ GetMacAddressString(
if (VlanId != 0) {
*String++ = L'\\';
- String += UnicodeValueToString (String, PREFIX_ZERO | RADIX_HEX, VlanId, 4);
+ UnicodeValueToStringS (
+ String,
+ BufferLen - ((UINTN)String - (UINTN)*PBuffer),
+ PREFIX_ZERO | RADIX_HEX,
+ VlanId,
+ 4
+ );
+ String += StrnLenS (String, (BufferLen - ((UINTN)String -
+ (UINTN)*PBuffer)) / sizeof (CHAR16));
}
//
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/FrontPage.c b/IntelFrameworkModulePkg/Universal/BdsDxe/FrontPage.c
index c771974..ec91422 100644
--- a/IntelFrameworkModulePkg/Universal/BdsDxe/FrontPage.c
+++ b/IntelFrameworkModulePkg/Universal/BdsDxe/FrontPage.c
@@ -1,7 +1,7 @@
/** @file
FrontPage routines to handle the callbacks and browser calls
-Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2017, 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 @@ -629,9 +629,16 @@ ConvertProcessorToString (
StringBuffer = AllocateZeroPool (0x20);
ASSERT (StringBuffer != NULL);
- Index = UnicodeValueToString (StringBuffer, LEFT_JUSTIFY, FreqMhz / 1000, 3);
+ UnicodeValueToStringS (StringBuffer, 0x20, LEFT_JUSTIFY, FreqMhz /
+ 1000, 3); Index = StrnLenS (StringBuffer, 0x20 / sizeof (CHAR16));
StrCatS (StringBuffer, 0x20 / sizeof (CHAR16), L".");
- UnicodeValueToString (StringBuffer + Index + 1, PREFIX_ZERO, (FreqMhz % 1000) / 10, 2);
+ UnicodeValueToStringS (
+ StringBuffer + Index + 1,
+ 0x20 - sizeof (CHAR16) * (Index + 1),
+ PREFIX_ZERO,
+ (FreqMhz % 1000) / 10,
+ 2
+ );
StrCatS (StringBuffer, 0x20 / sizeof (CHAR16), L" GHz");
*String = (CHAR16 *) StringBuffer;
return ;
@@ -655,7 +662,7 @@ ConvertMemorySizeToString (
StringBuffer = AllocateZeroPool (0x20);
ASSERT (StringBuffer != NULL);
- UnicodeValueToString (StringBuffer, LEFT_JUSTIFY, MemorySize, 6);
+ UnicodeValueToStringS (StringBuffer, 0x20, LEFT_JUSTIFY, MemorySize,
+ 6);
StrCatS (StringBuffer, 0x20 / sizeof (CHAR16), L" MB RAM");
*String = (CHAR16 *) StringBuffer;
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/MemoryTest.c b/IntelFrameworkModulePkg/Universal/BdsDxe/MemoryTest.c
index 700e3e6..1188082 100644
--- a/IntelFrameworkModulePkg/Universal/BdsDxe/MemoryTest.c
+++ b/IntelFrameworkModulePkg/Universal/BdsDxe/MemoryTest.c
@@ -1,7 +1,7 @@
/** @file
Perform the platform memory test
-Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2017, 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 @@ -318,7 +318,7 @@ BdsMemoryTest (
TempData
);
if (TestPercent != PreviousValue) {
- UnicodeValueToString (StrPercent, 0, TestPercent, 0);
+ UnicodeValueToStringS (StrPercent, sizeof (StrPercent), 0,
+ TestPercent, 0);
TmpStr = GetStringById (STRING_TOKEN (STR_MEMORY_TEST_PERCENT));
if (TmpStr != NULL) {
//
@@ -386,7 +386,7 @@ BdsMemoryTest (
Done:
if (!FeaturePcdGet(PcdBootlogoOnlyEnable)) {
- UnicodeValueToString (StrTotalMemory, COMMA_TYPE, TotalMemorySize, 0);
+ UnicodeValueToStringS (StrTotalMemory, StrTotalMemorySize,
+ COMMA_TYPE, TotalMemorySize, 0);
if (StrTotalMemory[0] == L',') {
StrTotalMemory++;
StrTotalMemorySize -= sizeof (CHAR16);
--
1.9.5.msysgit.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH 2/7] MdeModulePkg: Replace [Ascii|Unicode]ValueToString
2017-02-21 11:35 ` [PATCH 2/7] MdeModulePkg: " Hao Wu
@ 2017-02-28 8:13 ` Zeng, Star
0 siblings, 0 replies; 13+ messages in thread
From: Zeng, Star @ 2017-02-28 8:13 UTC (permalink / raw)
To: Wu, Hao A, edk2-devel@lists.01.org; +Cc: Yao, Jiewen, Tian, Feng
Reviewed-by: Star Zeng <star.zeng@intel.com>
-----Original Message-----
From: Wu, Hao A
Sent: Tuesday, February 21, 2017 7:35 PM
To: edk2-devel@lists.01.org
Cc: Wu, Hao A <hao.a.wu@intel.com>; Yao, Jiewen <jiewen.yao@intel.com>; Tian, Feng <feng.tian@intel.com>; Zeng, Star <star.zeng@intel.com>
Subject: [PATCH 2/7] MdeModulePkg: Replace [Ascii|Unicode]ValueToString
It is the follow up of commits 51f0ceb..9e32e97 to replace AsciiValueToString/UnicodeValueToString with AsciiValueToStringS/UnicodeValueToStringS.
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Feng Tian <feng.tian@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
---
MdeModulePkg/Application/UiApp/FrontPage.c | 15 +++++--
MdeModulePkg/Library/BootMaintenanceManagerUiLib/UpdatePage.c | 12 +++--
MdeModulePkg/Library/DeviceManagerUiLib/DeviceManager.c | 20 +++++++--
MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleReportLib.c | 10 ++++-
MdeModulePkg/Library/DxeNetLib/DxeNetLib.c | 24 ++++++++--
MdeModulePkg/Library/UefiHiiLib/HiiLib.c | 29 ++++++++++--
MdeModulePkg/Universal/CapsulePei/UefiCapsule.c | 18 ++++++--
MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleService.c | 10 ++++-
MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c | 37 +++++++++------
MdeModulePkg/Universal/HiiDatabaseDxe/ConfigKeywordHandler.c | 29 ++++++++++--
MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c | 47 +++++++++++++++++---
MdeModulePkg/Universal/Network/VlanConfigDxe/VlanConfigImpl.c | 14 ++++--
MdeModulePkg/Universal/SetupBrowserDxe/Expression.c | 11 ++++-
MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c | 4 +-
MdeModulePkg/Universal/SetupBrowserDxe/Setup.c | 38 +++++++++++++---
15 files changed, 258 insertions(+), 60 deletions(-)
diff --git a/MdeModulePkg/Application/UiApp/FrontPage.c b/MdeModulePkg/Application/UiApp/FrontPage.c
index bda5ff9..ad5af2c 100644
--- a/MdeModulePkg/Application/UiApp/FrontPage.c
+++ b/MdeModulePkg/Application/UiApp/FrontPage.c
@@ -1,7 +1,7 @@
/** @file
FrontPage routines to handle the callbacks and browser calls
-Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2017, 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 @@ -408,9 +408,16 @@ ConvertProcessorToString (
DestMax = 0x20 / sizeof (CHAR16);
StringBuffer = AllocateZeroPool (0x20);
ASSERT (StringBuffer != NULL);
- Index = UnicodeValueToString (StringBuffer, LEFT_JUSTIFY, FreqMhz / 1000, 3);
+ UnicodeValueToStringS (StringBuffer, sizeof (CHAR16) * DestMax,
+ LEFT_JUSTIFY, FreqMhz / 1000, 3); Index = StrnLenS (StringBuffer,
+ DestMax);
StrCatS (StringBuffer, DestMax, L".");
- UnicodeValueToString (StringBuffer + Index + 1, PREFIX_ZERO, (FreqMhz % 1000) / 10, 2);
+ UnicodeValueToStringS (
+ StringBuffer + Index + 1,
+ sizeof (CHAR16) * (DestMax - (Index + 1)),
+ PREFIX_ZERO,
+ (FreqMhz % 1000) / 10,
+ 2
+ );
StrCatS (StringBuffer, DestMax, L" GHz");
*String = (CHAR16 *) StringBuffer;
return ;
@@ -434,7 +441,7 @@ ConvertMemorySizeToString (
StringBuffer = AllocateZeroPool (0x24);
ASSERT (StringBuffer != NULL);
- UnicodeValueToString (StringBuffer, LEFT_JUSTIFY, MemorySize, 10);
+ UnicodeValueToStringS (StringBuffer, 0x24, LEFT_JUSTIFY, MemorySize,
+ 10);
StrCatS (StringBuffer, 0x24 / sizeof (CHAR16), L" MB RAM");
*String = (CHAR16 *) StringBuffer;
diff --git a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/UpdatePage.c b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/UpdatePage.c
index dede4b3..b3cc3c8 100644
--- a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/UpdatePage.c
+++ b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/UpdatePage.c
@@ -1,7 +1,7 @@
/** @file
Dynamically update the pages.
-Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2017, 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 @@ -734,11 +734,17 @@ UpdateConModePage (
//
// Build mode string Column x Row
//
- UnicodeValueToString (ModeString, 0, Col, 0);
+ UnicodeValueToStringS (ModeString, sizeof (ModeString), 0, Col, 0);
PStr = &ModeString[0];
StrnCatS (PStr, ARRAY_SIZE (ModeString), L" x ", StrLen(L" x ") + 1);
PStr = PStr + StrLen (PStr);
- UnicodeValueToString (PStr , 0, Row, 0);
+ UnicodeValueToStringS (
+ PStr,
+ sizeof (ModeString) - ((UINTN)PStr - (UINTN)&ModeString[0]),
+ 0,
+ Row,
+ 0
+ );
ModeToken[Index] = HiiSetString (CallbackData->BmmHiiHandle, 0, ModeString, NULL);
diff --git a/MdeModulePkg/Library/DeviceManagerUiLib/DeviceManager.c b/MdeModulePkg/Library/DeviceManagerUiLib/DeviceManager.c
index 0de4e3c..5098b70 100644
--- a/MdeModulePkg/Library/DeviceManagerUiLib/DeviceManager.c
+++ b/MdeModulePkg/Library/DeviceManagerUiLib/DeviceManager.c
@@ -1,7 +1,7 @@
/** @file
The device manager reference implementation
-Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2017, 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 @@ -148,7 +148,14 @@ GetMacAddressString(
//
HwAddress = &MacAddressNode->MacAddress.Addr[0];
for (Index = 0; Index < HwAddressSize; Index++) {
- String += UnicodeValueToString (String, PREFIX_ZERO | RADIX_HEX, *(HwAddress++), 2);
+ UnicodeValueToStringS (
+ String,
+ BufferLen - ((UINTN)String - (UINTN)*PBuffer),
+ PREFIX_ZERO | RADIX_HEX,
+ *(HwAddress++),
+ 2
+ );
+ String += StrnLenS (String, (BufferLen - ((UINTN)String -
+ (UINTN)*PBuffer)) / sizeof (CHAR16));
if (Index < HwAddressSize - 1) {
*String++ = L':';
}
@@ -168,7 +175,14 @@ GetMacAddressString(
if (VlanId != 0) {
*String++ = L'\\';
- String += UnicodeValueToString (String, PREFIX_ZERO | RADIX_HEX, VlanId, 4);
+ UnicodeValueToStringS (
+ String,
+ BufferLen - ((UINTN)String - (UINTN)*PBuffer),
+ PREFIX_ZERO | RADIX_HEX,
+ VlanId,
+ 4
+ );
+ String += StrnLenS (String, (BufferLen - ((UINTN)String -
+ (UINTN)*PBuffer)) / sizeof (CHAR16));
}
//
diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleReportLib.c b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleReportLib.c
index 3a9bb6e..fc0f869 100644
--- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleReportLib.c
+++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleReportLib.c
@@ -1,7 +1,7 @@
/** @file
DXE capsule report related function.
- Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2016 - 2017, 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 @@ -377,7 +377,13 @@ InitCapsuleUpdateVariable (
Index = 0;
while (TRUE) {
if (Index > 0) {
- UnicodeValueToString (TempVarName, 0, Index, 0);
+ UnicodeValueToStringS (
+ TempVarName,
+ sizeof (CapsuleVarName) - ((UINTN)TempVarName - (UINTN)CapsuleVarName),
+ 0,
+ Index,
+ 0
+ );
}
Status = gRT->SetVariable (
CapsuleVarName,
diff --git a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c
index 0a7117c..84e113d 100644
--- a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c
+++ b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c
@@ -1,7 +1,7 @@
/** @file
Network library.
-Copyright (c) 2005 - 2016, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2005 - 2017, Intel Corporation. All rights reserved.<BR>
(C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR> This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License @@ -2225,6 +2225,7 @@ NetLibGetMacString (
UINT16 VlanId;
CHAR16 *String;
UINTN Index;
+ UINTN BufferSize;
ASSERT (MacString != NULL);
@@ -2241,7 +2242,8 @@ NetLibGetMacString (
// If VLAN is configured, it will need extra 5 characters like "\0005".
// Plus one unicode character for the null-terminator.
//
- String = AllocateZeroPool ((2 * HwAddressSize + 5 + 1) * sizeof (CHAR16));
+ BufferSize = (2 * HwAddressSize + 5 + 1) * sizeof (CHAR16); String =
+ AllocateZeroPool (BufferSize);
if (String == NULL) {
return EFI_OUT_OF_RESOURCES;
}
@@ -2252,7 +2254,14 @@ NetLibGetMacString (
//
HwAddress = &MacAddress.Addr[0];
for (Index = 0; Index < HwAddressSize; Index++) {
- String += UnicodeValueToString (String, PREFIX_ZERO | RADIX_HEX, *(HwAddress++), 2);
+ UnicodeValueToStringS (
+ String,
+ BufferSize - ((UINTN)String - (UINTN)*MacString),
+ PREFIX_ZERO | RADIX_HEX,
+ *(HwAddress++),
+ 2
+ );
+ String += StrnLenS (String, (BufferSize - ((UINTN)String -
+ (UINTN)*MacString)) / sizeof (CHAR16));
}
//
@@ -2261,7 +2270,14 @@ NetLibGetMacString (
VlanId = NetLibGetVlanId (ServiceHandle);
if (VlanId != 0) {
*String++ = L'\\';
- String += UnicodeValueToString (String, PREFIX_ZERO | RADIX_HEX, VlanId, 4);
+ UnicodeValueToStringS (
+ String,
+ BufferSize - ((UINTN)String - (UINTN)*MacString),
+ PREFIX_ZERO | RADIX_HEX,
+ VlanId,
+ 4
+ );
+ String += StrnLenS (String, (BufferSize - ((UINTN)String -
+ (UINTN)*MacString)) / sizeof (CHAR16));
}
//
diff --git a/MdeModulePkg/Library/UefiHiiLib/HiiLib.c b/MdeModulePkg/Library/UefiHiiLib/HiiLib.c
index 8579501..b740d43 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 - 2016, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2006 - 2017, 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 @@ -776,7 +776,14 @@ HiiConstructConfigHdr (
// Append Guid converted to <HexCh>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));
}
}
@@ -791,7 +798,14 @@ HiiConstructConfigHdr (
// Append Name converted to <Char>NameLength
//
for (; *Name != L'\0'; Name++) {
- String += UnicodeValueToString (String, PREFIX_ZERO | RADIX_HEX, *Name, 4);
+ UnicodeValueToStringS (
+ String,
+ sizeof (CHAR16) * MaxLen - ((UINTN)String - (UINTN)ReturnString),
+ PREFIX_ZERO | RADIX_HEX,
+ *Name,
+ 4
+ );
+ String += StrnLenS (String, MaxLen - ((UINTN)String -
+ (UINTN)ReturnString) / sizeof (CHAR16));
}
}
@@ -805,7 +819,14 @@ HiiConstructConfigHdr (
// Append the device path associated with DriverHandle converted to <HexChar>DevicePathSize
//
for (Index = 0, Buffer = (UINT8 *)DevicePath; Index < DevicePathSize; Index++) {
- String += UnicodeValueToString (String, PREFIX_ZERO | RADIX_HEX, *(Buffer++), 2);
+ UnicodeValueToStringS (
+ String,
+ sizeof (CHAR16) * MaxLen - ((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/CapsulePei/UefiCapsule.c b/MdeModulePkg/Universal/CapsulePei/UefiCapsule.c
index 9ac9d22..53fe13f 100644
--- a/MdeModulePkg/Universal/CapsulePei/UefiCapsule.c
+++ b/MdeModulePkg/Universal/CapsulePei/UefiCapsule.c
@@ -1,7 +1,7 @@
/** @file
Capsule update PEIM for UEFI2.0
-Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available under the terms and conditions @@ -768,7 +768,13 @@ GetCapsuleDescriptors (
return EFI_SUCCESS;
}
} else {
- UnicodeValueToString (TempVarName, 0, Index, 0);
+ UnicodeValueToStringS (
+ TempVarName,
+ sizeof (CapsuleVarName) - ((UINTN)TempVarName - (UINTN)CapsuleVarName),
+ 0,
+ Index,
+ 0
+ );
Status = PPIVariableServices->GetVariable (
PPIVariableServices,
CapsuleVarName, @@ -891,7 +897,13 @@ CapsuleCoalesce (
TempVarName = CapsuleVarName + StrLen (CapsuleVarName);
while (TRUE) {
if (Index > 0) {
- UnicodeValueToString (TempVarName, 0, Index, 0);
+ UnicodeValueToStringS (
+ TempVarName,
+ sizeof (CapsuleVarName) - ((UINTN)TempVarName - (UINTN)CapsuleVarName),
+ 0,
+ Index,
+ 0
+ );
}
Status = PPIVariableServices->GetVariable (
PPIVariableServices, diff --git a/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleService.c b/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleService.c
index ed8820a..216798d 100644
--- a/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleService.c
+++ b/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleService.c
@@ -4,7 +4,7 @@
It installs the Capsule Architectural Protocol defined in PI1.0a to signify
the capsule runtime services are ready.
-Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2017, 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 @@ -205,7 +205,13 @@ UpdateCapsule (
StrCpyS (CapsuleVarName, sizeof(CapsuleVarName)/sizeof(CHAR16), EFI_CAPSULE_VARIABLE_NAME);
TempVarName = CapsuleVarName + StrLen (CapsuleVarName);
if (mTimes > 0) {
- UnicodeValueToString (TempVarName, 0, mTimes, 0);
+ UnicodeValueToStringS (
+ TempVarName,
+ sizeof (CapsuleVarName) - ((UINTN)TempVarName - (UINTN)CapsuleVarName),
+ 0,
+ mTimes,
+ 0
+ );
}
//
diff --git a/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c b/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c
index 67a40b7..f103b9c 100644
--- a/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c
+++ b/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c
@@ -725,12 +725,14 @@ ExtractConfig (
BackupChar = Value[ValueStrLen];
*Value++ = L'=';
- Value += UnicodeValueToString (
- Value,
- PREFIX_ZERO | RADIX_HEX,
- PrivateData->Configuration.NameValueVar0,
- sizeof (PrivateData->Configuration.NameValueVar0) * 2
- );
+ UnicodeValueToStringS (
+ Value,
+ BufferSize - ((UINTN)Value - (UINTN)*Results),
+ PREFIX_ZERO | RADIX_HEX,
+ PrivateData->Configuration.NameValueVar0,
+ sizeof (PrivateData->Configuration.NameValueVar0) * 2
+ );
+ Value += StrnLenS (Value, (BufferSize - ((UINTN)Value -
+ (UINTN)*Results)) / sizeof (CHAR16));
*Value = BackupChar;
}
@@ -744,12 +746,14 @@ ExtractConfig (
BackupChar = Value[ValueStrLen];
*Value++ = L'=';
- Value += UnicodeValueToString (
- Value,
- PREFIX_ZERO | RADIX_HEX,
- PrivateData->Configuration.NameValueVar1,
- sizeof (PrivateData->Configuration.NameValueVar1) * 2
- );
+ UnicodeValueToStringS (
+ Value,
+ BufferSize - ((UINTN)Value - (UINTN)*Results),
+ PREFIX_ZERO | RADIX_HEX,
+ PrivateData->Configuration.NameValueVar1,
+ sizeof (PrivateData->Configuration.NameValueVar1) * 2
+ );
+ Value += StrnLenS (Value, (BufferSize - ((UINTN)Value -
+ (UINTN)*Results)) / sizeof (CHAR16));
*Value = BackupChar;
}
@@ -767,7 +771,14 @@ ExtractConfig (
//
StrPointer = (CHAR16 *) PrivateData->Configuration.NameValueVar2;
for (; *StrPointer != L'\0'; StrPointer++) {
- Value += UnicodeValueToString (Value, PREFIX_ZERO | RADIX_HEX, *StrPointer, 4);
+ UnicodeValueToStringS (
+ Value,
+ BufferSize - ((UINTN)Value - (UINTN)*Results),
+ PREFIX_ZERO | RADIX_HEX,
+ *StrPointer,
+ 4
+ );
+ Value += StrnLenS (Value, (BufferSize - ((UINTN)Value -
+ (UINTN)*Results)) / sizeof (CHAR16));
}
}
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.<BR>
+Copyright (c) 2015 - 2017, 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 @@ -1763,7 +1763,14 @@ ConstructConfigHdr (
// Append Guid converted to <HexCh>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 <Char>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 <HexChar>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 d547f42..eafc037 100644
--- a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c
+++ b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c
@@ -1,7 +1,7 @@
/** @file
Implementation of interfaces function for EFI_HII_CONFIG_ROUTING_PROTOCOL.
-Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2007 - 2017, 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 @@ -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:
@@ -3703,7 +3724,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);
@@ -5390,7 +5418,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);
diff --git a/MdeModulePkg/Universal/Network/VlanConfigDxe/VlanConfigImpl.c b/MdeModulePkg/Universal/Network/VlanConfigDxe/VlanConfigImpl.c
index 5e0fe42..f035706 100644
--- a/MdeModulePkg/Universal/Network/VlanConfigDxe/VlanConfigImpl.c
+++ b/MdeModulePkg/Universal/Network/VlanConfigDxe/VlanConfigImpl.c
@@ -1,7 +1,7 @@
/** @file
HII Config Access protocol implementation of VLAN configuration module.
-Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2009 - 2017, 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 @@ -417,14 +417,22 @@ VlanUpdateForm (
//
// Pad VlanId string up to 4 characters with space
//
- DigitalCount = UnicodeValueToString (VlanIdStr, 0, VlanData[Index].VlanId, 5);
+ UnicodeValueToStringS (VlanIdStr, sizeof (VlanIdStr), 0, VlanData[Index].VlanId, 5);
+ DigitalCount = StrnLenS (VlanIdStr, ARRAY_SIZE (VlanIdStr));
SetMem16 (String, (4 - DigitalCount) * sizeof (CHAR16), L' ');
StrCpyS (String + 4 - DigitalCount, (sizeof (VlanStr) /sizeof (CHAR16)) - 10 - (4 - DigitalCount), VlanIdStr);
String += 4;
StrCpyS (String, (sizeof (VlanStr) /sizeof (CHAR16)) - 10 - (4 - DigitalCount) - 4, L", Priority:");
String += 11;
- String += UnicodeValueToString (String, 0, VlanData[Index].Priority, 4);
+ UnicodeValueToStringS (
+ String,
+ sizeof (VlanStr) - ((UINTN)String - (UINTN)VlanStr),
+ 0,
+ VlanData[Index].Priority,
+ 4
+ );
+ String += StrnLenS (String, ARRAY_SIZE (VlanStr) - ((UINTN)String -
+ (UINTN)VlanStr) / sizeof (CHAR16));
*String = 0;
StringId = HiiSetString (PrivateData->HiiHandle, 0, VlanStr, NULL); diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Expression.c b/MdeModulePkg/Universal/SetupBrowserDxe/Expression.c
index ec4d285..901b35c 100644
--- a/MdeModulePkg/Universal/SetupBrowserDxe/Expression.c
+++ b/MdeModulePkg/Universal/SetupBrowserDxe/Expression.c
@@ -1,7 +1,7 @@
/** @file
Utility functions for expression evaluation.
-Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2007 - 2017, 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 @@ -3143,7 +3143,14 @@ EvaluateExpression (
TempBuffer = (UINT8 *) &Value->Value + OpCode->ValueWidth - 1;
StrPtr = NameValue;
for (Index = 0; Index < OpCode->ValueWidth; Index ++, TempBuffer --) {
- StrPtr += UnicodeValueToString (StrPtr, PREFIX_ZERO | RADIX_HEX, *TempBuffer, 2);
+ UnicodeValueToStringS (
+ StrPtr,
+ (OpCode->ValueWidth * 2 + 1) * sizeof (CHAR16) - ((UINTN)StrPtr - (UINTN)NameValue),
+ PREFIX_ZERO | RADIX_HEX,
+ *TempBuffer,
+ 2
+ );
+ StrPtr += StrnLenS (StrPtr, OpCode->ValueWidth * 2 + 1 -
+ ((UINTN)StrPtr - (UINTN)NameValue) / sizeof (CHAR16));
}
Status = SetValueByName (OpCode->VarStorage, OpCode->ValueName, NameValue, GetSetValueWithEditBuffer, NULL);
FreePool (NameValue);
diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c b/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c
index 61ba0b5..6b3e5e0 100644
--- a/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c
+++ b/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c
@@ -1,7 +1,7 @@
/** @file
Parser for IFR binary encoding.
-Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2007 - 2017, 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 @@ -116,7 +116,7 @@ UpdateCheckBoxStringToken (
ASSERT (Statement != NULL);
ASSERT (Statement->Operand == EFI_IFR_NUMERIC_OP);
- UnicodeValueToString (Str, 0, Statement->VarStoreInfo.VarName, MAXIMUM_VALUE_CHARACTERS - 1);
+ UnicodeValueToStringS (Str, sizeof (Str), 0,
+ Statement->VarStoreInfo.VarName, MAXIMUM_VALUE_CHARACTERS - 1);
Id = HiiSetString (FormSet->HiiHandle, 0, Str, NULL);
if (Id == 0) {
diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c
index 06e682a..83dc2b8 100644
--- a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c
+++ b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c
@@ -1,7 +1,7 @@
/** @file
Entry and initialization module for the browser.
-Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2007 - 2017, 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 @@ -1972,7 +1972,14 @@ SetQuestionValue (
TemName = (CHAR16 *) Src;
TemString = Value;
for (; *TemName != L'\0'; TemName++) {
- TemString += UnicodeValueToString (TemString, PREFIX_ZERO | RADIX_HEX, *TemName, 4);
+ UnicodeValueToStringS (
+ TemString,
+ BufferLen - ((UINTN)TemString - (UINTN)Value),
+ PREFIX_ZERO | RADIX_HEX,
+ *TemName,
+ 4
+ );
+ TemString += StrnLenS (TemString, (BufferLen -
+ ((UINTN)TemString - (UINTN)Value)) / sizeof (CHAR16));
}
} else {
BufferLen = StorageWidth * 2 + 1; @@ -1984,7 +1991,14 @@ SetQuestionValue (
TemBuffer = Src + StorageWidth - 1;
TemString = Value;
for (Index = 0; Index < StorageWidth; Index ++, TemBuffer --) {
- TemString += UnicodeValueToString (TemString, PREFIX_ZERO | RADIX_HEX, *TemBuffer, 2);
+ UnicodeValueToStringS (
+ TemString,
+ BufferLen * sizeof (CHAR16) - ((UINTN)TemString - (UINTN)Value),
+ PREFIX_ZERO | RADIX_HEX,
+ *TemBuffer,
+ 2
+ );
+ TemString += StrnLenS (TemString, BufferLen -
+ ((UINTN)TemString - (UINTN)Value) / sizeof (CHAR16));
}
}
@@ -2034,7 +2048,14 @@ SetQuestionValue (
TemName = (CHAR16 *) Src;
TemString = Value;
for (; *TemName != L'\0'; TemName++) {
- TemString += UnicodeValueToString (TemString, PREFIX_ZERO | RADIX_HEX, *TemName, 4);
+ UnicodeValueToStringS (
+ TemString,
+ MaxLen * sizeof (CHAR16) - ((UINTN)TemString - (UINTN)ConfigResp),
+ PREFIX_ZERO | RADIX_HEX,
+ *TemName,
+ 4
+ );
+ TemString += StrnLenS (TemString, MaxLen - ((UINTN)TemString -
+ (UINTN)ConfigResp) / sizeof (CHAR16));
}
} else {
//
@@ -2043,7 +2064,14 @@ SetQuestionValue (
TemBuffer = Src + StorageWidth - 1;
TemString = Value;
for (Index = 0; Index < StorageWidth; Index ++, TemBuffer --) {
- TemString += UnicodeValueToString (TemString, PREFIX_ZERO | RADIX_HEX, *TemBuffer, 2);
+ UnicodeValueToStringS (
+ TemString,
+ MaxLen * sizeof (CHAR16) - ((UINTN)TemString - (UINTN)ConfigResp),
+ PREFIX_ZERO | RADIX_HEX,
+ *TemBuffer,
+ 2
+ );
+ TemString += StrnLenS (TemString, MaxLen - ((UINTN)TemString -
+ (UINTN)ConfigResp) / sizeof (CHAR16));
}
}
--
1.9.5.msysgit.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
end of thread, other threads:[~2017-02-28 8:13 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-02-21 11:35 [PATCH 0/7] Mark [Ascii|Unicode]ValueToString as deprecated Hao Wu
2017-02-21 11:35 ` [PATCH 1/7] IntelFrameworkModulePkg: Replace [Ascii|Unicode]ValueToString Hao Wu
2017-02-27 7:36 ` Fan, Jeff
2017-02-21 11:35 ` [PATCH 2/7] MdeModulePkg: " Hao Wu
2017-02-28 8:13 ` Zeng, Star
2017-02-21 11:35 ` [PATCH 3/7] Nt32Pkg: " Hao Wu
2017-02-22 1:57 ` Ni, Ruiyu
2017-02-21 11:35 ` [PATCH 4/7] SignedCapsulePkg: " Hao Wu
2017-02-27 1:09 ` Yao, Jiewen
2017-02-21 11:35 ` [PATCH 5/7] MdeModulePkg/PrintDxe: Handle the deprecation of [A|U]ValueToString Hao Wu
2017-02-21 11:35 ` [PATCH 6/7] MdeModulePkg/PrintLib: Add deprecated flag for APIs [A|U]ValueToString Hao Wu
2017-02-21 11:35 ` [PATCH 7/7] MdePkg/BasePrintLib: " Hao Wu
2017-02-23 1:50 ` [PATCH 0/7] Mark [Ascii|Unicode]ValueToString as deprecated Gao, Liming
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox