From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 794A981EE0 for ; Tue, 28 Feb 2017 00:13:20 -0800 (PST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga105.fm.intel.com with ESMTP; 28 Feb 2017 00:13:20 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.35,218,1484035200"; d="scan'208";a="1116481128" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by fmsmga001.fm.intel.com with ESMTP; 28 Feb 2017 00:13:19 -0800 Received: from fmsmsx117.amr.corp.intel.com (10.18.116.17) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.248.2; Tue, 28 Feb 2017 00:13:18 -0800 Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by fmsmsx117.amr.corp.intel.com (10.18.116.17) with Microsoft SMTP Server (TLS) id 14.3.248.2; Tue, 28 Feb 2017 00:13:18 -0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.88]) by SHSMSX103.ccr.corp.intel.com ([10.239.4.69]) with mapi id 14.03.0248.002; Tue, 28 Feb 2017 16:13:17 +0800 From: "Zeng, Star" To: "Wu, Hao A" , "edk2-devel@lists.01.org" CC: "Yao, Jiewen" , "Tian, Feng" Thread-Topic: [PATCH 2/7] MdeModulePkg: Replace [Ascii|Unicode]ValueToString Thread-Index: AQHSjDa1jrueyASuF0+1ZebBsAtbKKF+HIpQ Date: Tue, 28 Feb 2017 08:13:17 +0000 Message-ID: <0C09AFA07DD0434D9E2A0C6AEB0483103B82CD6C@shsmsx102.ccr.corp.intel.com> References: <1487676934-12984-1-git-send-email-hao.a.wu@intel.com> <1487676934-12984-3-git-send-email-hao.a.wu@intel.com> In-Reply-To: <1487676934-12984-3-git-send-email-hao.a.wu@intel.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH 2/7] MdeModulePkg: Replace [Ascii|Unicode]ValueToString X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 28 Feb 2017 08:13:20 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Star Zeng -----Original Message----- From: Wu, Hao A=20 Sent: Tuesday, February 21, 2017 7:35 PM To: edk2-devel@lists.01.org Cc: Wu, Hao A ; Yao, Jiewen ; Tia= n, Feng ; Zeng, Star Subject: [PATCH 2/7] MdeModulePkg: Replace [Ascii|Unicode]ValueToString It is the follow up of commits 51f0ceb..9e32e97 to replace AsciiValueToStri= ng/UnicodeValueToString with AsciiValueToStringS/UnicodeValueToStringS. Cc: Jiewen Yao Cc: Feng Tian Cc: Star Zeng Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Hao Wu --- 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/Appl= ication/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 =20 -Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made availab= le under the terms and conditions of the BSD License which accompanies thi= s distribution. The full text of the license may be found at @@ -408,9 +40= 8,16 @@ ConvertProcessorToString ( DestMax =3D 0x20 / sizeof (CHAR16); StringBuffer =3D AllocateZeroPool (0x20); ASSERT (StringBuffer !=3D NULL); - Index =3D UnicodeValueToString (StringBuffer, LEFT_JUSTIFY, FreqMhz / 10= 00, 3); + UnicodeValueToStringS (StringBuffer, sizeof (CHAR16) * DestMax,=20 + LEFT_JUSTIFY, FreqMhz / 1000, 3); Index =3D StrnLenS (StringBuffer,=20 + 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 =3D (CHAR16 *) StringBuffer; return ; @@ -434,7 +441,7 @@ ConvertMemorySizeToString ( =20 StringBuffer =3D AllocateZeroPool (0x24); ASSERT (StringBuffer !=3D NULL); - UnicodeValueToString (StringBuffer, LEFT_JUSTIFY, MemorySize, 10); + UnicodeValueToStringS (StringBuffer, 0x24, LEFT_JUSTIFY, MemorySize,=20 + 10); StrCatS (StringBuffer, 0x24 / sizeof (CHAR16), L" MB RAM"); =20 *String =3D (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. =20 -Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made availab= le under the terms and conditions of the BSD License which accompanies thi= s distribution. The full text of the license may be found at @@ -734,11 +7= 34,17 @@ UpdateConModePage ( // // Build mode string Column x Row // - UnicodeValueToString (ModeString, 0, Col, 0); + UnicodeValueToStringS (ModeString, sizeof (ModeString), 0, Col, 0); PStr =3D &ModeString[0]; StrnCatS (PStr, ARRAY_SIZE (ModeString), L" x ", StrLen(L" x ") + 1); PStr =3D PStr + StrLen (PStr); - UnicodeValueToString (PStr , 0, Row, 0); + UnicodeValueToStringS ( + PStr, + sizeof (ModeString) - ((UINTN)PStr - (UINTN)&ModeString[0]), + 0, + Row, + 0 + ); =20 ModeToken[Index] =3D HiiSetString (CallbackData->BmmHiiHandle, 0, Mode= String, NULL); =20 diff --git a/MdeModulePkg/Library/DeviceManagerUiLib/DeviceManager.c b/MdeM= odulePkg/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 =20 -Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made availab= le under the terms and conditions of the BSD License which accompanies thi= s distribution. The full text of the license may be found at @@ -148,7 +14= 8,14 @@ GetMacAddressString( // HwAddress =3D &MacAddressNode->MacAddress.Addr[0]; for (Index =3D 0; Index < HwAddressSize; Index++) { - String +=3D UnicodeValueToString (String, PREFIX_ZERO | RADIX_HEX, *(H= wAddress++), 2); + UnicodeValueToStringS ( + String, + BufferLen - ((UINTN)String - (UINTN)*PBuffer), + PREFIX_ZERO | RADIX_HEX, + *(HwAddress++), + 2 + ); + String +=3D StrnLenS (String, (BufferLen - ((UINTN)String -=20 + (UINTN)*PBuffer)) / sizeof (CHAR16)); if (Index < HwAddressSize - 1) { *String++ =3D L':'; } @@ -168,7 +175,14 @@ GetMacAddressString( =20 if (VlanId !=3D 0) { *String++ =3D L'\\'; - String +=3D UnicodeValueToString (String, PREFIX_ZERO | RADIX_HEX, Vla= nId, 4); + UnicodeValueToStringS ( + String, + BufferLen - ((UINTN)String - (UINTN)*PBuffer), + PREFIX_ZERO | RADIX_HEX, + VlanId, + 4 + ); + String +=3D StrnLenS (String, (BufferLen - ((UINTN)String -=20 + (UINTN)*PBuffer)) / sizeof (CHAR16)); } =20 // 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. =20 - Copyright (c) 2016, Intel Corporation. All rights reserved.
+ Copyright (c) 2016 - 2017, Intel Corporation. All rights=20 + reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BS= D License which accompanies this distribution. The full text of the license may b= e found at @@ -377,7 +377,13 @@ InitCapsuleUpdateVariable ( Index =3D 0; while (TRUE) { if (Index > 0) { - UnicodeValueToString (TempVarName, 0, Index, 0); + UnicodeValueToStringS ( + TempVarName, + sizeof (CapsuleVarName) - ((UINTN)TempVarName - (UINTN)CapsuleVarN= ame), + 0, + Index, + 0 + ); } Status =3D gRT->SetVariable ( CapsuleVarName, diff --git a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c b/MdeModulePkg/Libr= ary/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. =20 -Copyright (c) 2005 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2005 - 2017, Intel Corporation. All rights reserved.
(C) Copyright 2015 Hewlett Packard Enterprise Development LP
This pro= gram and the accompanying materials are licensed and made available under = the terms and conditions of the BSD License @@ -2225,6 +2225,7 @@ NetLibGet= MacString ( UINT16 VlanId; CHAR16 *String; UINTN Index; + UINTN BufferSize; =20 ASSERT (MacString !=3D NULL); =20 @@ -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 =3D AllocateZeroPool ((2 * HwAddressSize + 5 + 1) * sizeof (CHAR1= 6)); + BufferSize =3D (2 * HwAddressSize + 5 + 1) * sizeof (CHAR16); String = =3D=20 + AllocateZeroPool (BufferSize); if (String =3D=3D NULL) { return EFI_OUT_OF_RESOURCES; } @@ -2252,7 +2254,14 @@ NetLibGetMacString ( // HwAddress =3D &MacAddress.Addr[0]; for (Index =3D 0; Index < HwAddressSize; Index++) { - String +=3D UnicodeValueToString (String, PREFIX_ZERO | RADIX_HEX, *(H= wAddress++), 2); + UnicodeValueToStringS ( + String, + BufferSize - ((UINTN)String - (UINTN)*MacString), + PREFIX_ZERO | RADIX_HEX, + *(HwAddress++), + 2 + ); + String +=3D StrnLenS (String, (BufferSize - ((UINTN)String -=20 + (UINTN)*MacString)) / sizeof (CHAR16)); } =20 // @@ -2261,7 +2270,14 @@ NetLibGetMacString ( VlanId =3D NetLibGetVlanId (ServiceHandle); if (VlanId !=3D 0) { *String++ =3D L'\\'; - String +=3D UnicodeValueToString (String, PREFIX_ZERO | RADIX_HEX, Vla= nId, 4); + UnicodeValueToStringS ( + String, + BufferSize - ((UINTN)String - (UINTN)*MacString), + PREFIX_ZERO | RADIX_HEX, + VlanId, + 4 + ); + String +=3D StrnLenS (String, (BufferSize - ((UINTN)String -=20 + (UINTN)*MacString)) / sizeof (CHAR16)); } =20 // diff --git a/MdeModulePkg/Library/UefiHiiLib/HiiLib.c b/MdeModulePkg/Librar= y/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. =20 - Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
+ Copyright (c) 2006 - 2017, Intel Corporation. All rights=20 + reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BS= D License which accompanies this distribution. The full text of the license may b= e found at @@ -776,7 +776,14 @@ HiiConstructConfigHdr ( // Append Guid converted to 32 // for (Index =3D 0, Buffer =3D (UINT8 *)Guid; Index < sizeof (EFI_GUID);= Index++) { - String +=3D UnicodeValueToString (String, PREFIX_ZERO | RADIX_HEX, *= (Buffer++), 2); + UnicodeValueToStringS ( + String, + MaxLen * sizeof (CHAR16) - ((UINTN)String - (UINTN)ReturnString), + PREFIX_ZERO | RADIX_HEX, + *(Buffer++), + 2 + ); + String +=3D StrnLenS (String, MaxLen - ((UINTN)String -=20 + (UINTN)ReturnString) / sizeof (CHAR16)); } } =20 @@ -791,7 +798,14 @@ HiiConstructConfigHdr ( // Append Name converted to NameLength // for (; *Name !=3D L'\0'; Name++) { - String +=3D UnicodeValueToString (String, PREFIX_ZERO | RADIX_HEX, *= Name, 4); + UnicodeValueToStringS ( + String, + sizeof (CHAR16) * MaxLen - ((UINTN)String - (UINTN)ReturnString), + PREFIX_ZERO | RADIX_HEX, + *Name, + 4 + ); + String +=3D StrnLenS (String, MaxLen - ((UINTN)String -=20 + (UINTN)ReturnString) / sizeof (CHAR16)); } } =20 @@ -805,7 +819,14 @@ HiiConstructConfigHdr ( // Append the device path associated with DriverHandle converted to DevicePathSize // for (Index =3D 0, Buffer =3D (UINT8 *)DevicePath; Index < DevicePathSize= ; Index++) { - String +=3D UnicodeValueToString (String, PREFIX_ZERO | RADIX_HEX, *(B= uffer++), 2); + UnicodeValueToStringS ( + String, + sizeof (CHAR16) * MaxLen - ((UINTN)String - (UINTN)ReturnString), + PREFIX_ZERO | RADIX_HEX, + *(Buffer++), + 2 + ); + String +=3D StrnLenS (String, MaxLen - ((UINTN)String -=20 + (UINTN)ReturnString) / sizeof (CHAR16)); } =20 // 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 =20 -Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
=20 This program and the accompanying materials are licensed and made availab= le under the terms and conditions @@ -768,7 +768,13 @@ GetCapsuleDescriptor= s ( return EFI_SUCCESS; } } else { - UnicodeValueToString (TempVarName, 0, Index, 0); + UnicodeValueToStringS ( + TempVarName, + sizeof (CapsuleVarName) - ((UINTN)TempVarName - (UINTN)CapsuleVa= rName), + 0, + Index, + 0 + ); Status =3D PPIVariableServices->GetVariable ( PPIVariableServices, CapsuleVarName, @@ -891,7 +897,13 = @@ CapsuleCoalesce ( TempVarName =3D CapsuleVarName + StrLen (CapsuleVarName); while (TRUE) { if (Index > 0) { - UnicodeValueToString (TempVarName, 0, Index, 0); + UnicodeValueToStringS ( + TempVarName, + sizeof (CapsuleVarName) - ((UINTN)TempVarName - (UINTN)CapsuleVarN= ame), + 0, + Index, + 0 + ); } Status =3D PPIVariableServices->GetVariable ( PPIVariableServices, diff --git a/MdeM= odulePkg/Universal/CapsuleRuntimeDxe/CapsuleService.c b/MdeModulePkg/Univer= sal/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 sign= ify=20 the capsule runtime services are ready. =20 -Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made availab= le under the terms and conditions of the BSD License which accompanies thi= s distribution. The full text of the license may be found at @@ -205,7 +20= 5,13 @@ UpdateCapsule ( StrCpyS (CapsuleVarName, sizeof(CapsuleVarName)/sizeof(CHAR16), EFI_CAPS= ULE_VARIABLE_NAME); TempVarName =3D CapsuleVarName + StrLen (CapsuleVarName); if (mTimes > 0) { - UnicodeValueToString (TempVarName, 0, mTimes, 0); + UnicodeValueToStringS ( + TempVarName, + sizeof (CapsuleVarName) - ((UINTN)TempVarName - (UINTN)CapsuleVarNam= e), + 0, + mTimes, + 0 + ); } =20 // diff --git a/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c b/MdeMod= ulePkg/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 ( =20 BackupChar =3D Value[ValueStrLen]; *Value++ =3D L'=3D'; - Value +=3D UnicodeValueToString ( - Value,=20 - PREFIX_ZERO | RADIX_HEX,=20 - PrivateData->Configuration.NameValueVar0,=20 - 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 +=3D StrnLenS (Value, (BufferSize - ((UINTN)Value -=20 + (UINTN)*Results)) / sizeof (CHAR16)); *Value =3D BackupChar; } =20 @@ -744,12 +746,14 @@ ExtractConfig ( =20 BackupChar =3D Value[ValueStrLen]; *Value++ =3D L'=3D'; - Value +=3D UnicodeValueToString ( - Value,=20 - PREFIX_ZERO | RADIX_HEX,=20 - PrivateData->Configuration.NameValueVar1,=20 - 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 +=3D StrnLenS (Value, (BufferSize - ((UINTN)Value -=20 + (UINTN)*Results)) / sizeof (CHAR16)); *Value =3D BackupChar; } =20 @@ -767,7 +771,14 @@ ExtractConfig ( // StrPointer =3D (CHAR16 *) PrivateData->Configuration.NameValueVar2; for (; *StrPointer !=3D L'\0'; StrPointer++) { - Value +=3D UnicodeValueToString (Value, PREFIX_ZERO | RADIX_HEX, *= StrPointer, 4); + UnicodeValueToStringS ( + Value, + BufferSize - ((UINTN)Value - (UINTN)*Results), + PREFIX_ZERO | RADIX_HEX, + *StrPointer, + 4 + ); + Value +=3D StrnLenS (Value, (BufferSize - ((UINTN)Value -=20 + (UINTN)*Results)) / sizeof (CHAR16)); } } =20 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_PROTO= COL. =20 -Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made availab= le under the terms and conditions of the BSD License which accompanies thi= s distribution. The full text of the license may be found at @@ -1763,7 +1= 763,14 @@ ConstructConfigHdr ( // Append Guid converted to 32 // for (Index =3D 0, Buffer =3D (UINT8 *)Guid; Index < sizeof (EFI_GUID);= Index++) { - String +=3D UnicodeValueToString (String, PREFIX_ZERO | RADIX_HEX, *= (Buffer++), 2); + UnicodeValueToStringS ( + String, + MaxLen * sizeof (CHAR16) - ((UINTN)String - (UINTN)ReturnString), + PREFIX_ZERO | RADIX_HEX, + *(Buffer++), + 2 + ); + String +=3D StrnLenS (String, MaxLen - ((UINTN)String -=20 + (UINTN)ReturnString) / sizeof (CHAR16)); } } =20 @@ -1778,7 +1785,14 @@ ConstructConfigHdr ( // Append Name converted to NameLength // for (; *Name !=3D L'\0'; Name++) { - String +=3D UnicodeValueToString (String, PREFIX_ZERO | RADIX_HEX, *= Name, 4); + UnicodeValueToStringS ( + String, + MaxLen * sizeof (CHAR16) - ((UINTN)String - (UINTN)ReturnString), + PREFIX_ZERO | RADIX_HEX, + *Name, + 4 + ); + String +=3D StrnLenS (String, MaxLen - ((UINTN)String -=20 + (UINTN)ReturnString) / sizeof (CHAR16)); } } =20 @@ -1792,7 +1806,14 @@ ConstructConfigHdr ( // Append the device path associated with DriverHandle converted to DevicePathSize // for (Index =3D 0, Buffer =3D (UINT8 *)DevicePath; Index < DevicePathSize= ; Index++) { - String +=3D UnicodeValueToString (String, PREFIX_ZERO | RADIX_HEX, *(B= uffer++), 2); + UnicodeValueToStringS ( + String, + MaxLen * sizeof (CHAR16) - ((UINTN)String - (UINTN)ReturnString), + PREFIX_ZERO | RADIX_HEX, + *(Buffer++), + 2 + ); + String +=3D StrnLenS (String, MaxLen - ((UINTN)String -=20 + (UINTN)ReturnString) / sizeof (CHAR16)); } =20 // diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c b/MdeMod= ulePkg/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. =20 -Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made availab= le under the terms and conditions of the BSD License which accompanies thi= s distribution. The full text of the license may be found at @@ -264,7 +26= 4,14 @@ GenerateSubStr ( // TemBuffer =3D ((UINT8 *) Buffer); for (Index =3D 0; Index < BufferLen; Index ++, TemBuffer ++) { - TemString +=3D UnicodeValueToString (TemString, PREFIX_ZERO | RADIX_= HEX, *TemBuffer, 2); + UnicodeValueToStringS ( + TemString, + sizeof (CHAR16) * (Length - StrnLenS (Str, Length)), + PREFIX_ZERO | RADIX_HEX, + *TemBuffer, + 2 + ); + TemString +=3D StrnLenS (TemString, Length - StrnLenS (Str,=20 + Length)); } break; case 2: @@ -277,7 +284,14 @@ GenerateSubStr ( // Convert Unicode String to Config String, e.g. "ABCD" =3D> "00410042= 00430044" // for (; *TemName !=3D L'\0'; TemName++) { - TemString +=3D UnicodeValueToString (TemString, PREFIX_ZERO | RADIX_= HEX, *TemName, 4); + UnicodeValueToStringS ( + TemString, + sizeof (CHAR16) * (Length - StrnLenS (Str, Length)), + PREFIX_ZERO | RADIX_HEX, + *TemName, + 4 + ); + TemString +=3D StrnLenS (TemString, Length - StrnLenS (Str,=20 + Length)); } break; case 3: @@ -286,7 +300,14 @@ GenerateSubStr ( // TemBuffer =3D ((UINT8 *) Buffer) + BufferLen - 1; for (Index =3D 0; Index < BufferLen; Index ++, TemBuffer --) { - TemString +=3D UnicodeValueToString (TemString, PREFIX_ZERO | RADIX_= HEX, *TemBuffer, 2); + UnicodeValueToStringS ( + TemString, + sizeof (CHAR16) * (Length - StrnLenS (Str, Length)), + PREFIX_ZERO | RADIX_HEX, + *TemBuffer, + 2 + ); + TemString +=3D StrnLenS (TemString, Length - StrnLenS (Str,=20 + Length)); } break; default: @@ -3703,7 +3724,14 @@ GenerateAltConfigResp ( TmpBuffer =3D (UINT8 *) &(DefaultValueData->Value); } for (; Width > 0 && (TmpBuffer !=3D NULL); Width--) { - StringPtr +=3D UnicodeValueToString (StringPtr, PREFIX_ZERO | RA= DIX_HEX, TmpBuffer[Width - 1], 2); + UnicodeValueToStringS ( + StringPtr, + Length * sizeof (CHAR16) - ((UINTN)StringPtr - (UINTN)*Default= AltCfgResp), + PREFIX_ZERO | RADIX_HEX, + TmpBuffer[Width - 1], + 2 + ); + StringPtr +=3D StrnLenS (StringPtr, Length - ((UINTN)StringPtr=20 + - (UINTN)*DefaultAltCfgResp) / sizeof (CHAR16)); } if (DefaultString !=3D NULL){ FreePool(DefaultString); @@ -5390,7 +5418,14 @@ HiiBlockToConfig ( TemString =3D ValueStr; TemBuffer =3D Value + Width - 1; for (Index =3D 0; Index < Width; Index ++, TemBuffer --) { - TemString +=3D UnicodeValueToString (TemString, PREFIX_ZERO | RADIX_= HEX, *TemBuffer, 2); + UnicodeValueToStringS ( + TemString, + Length * sizeof (CHAR16) - ((UINTN)TemString - (UINTN)ValueStr), + PREFIX_ZERO | RADIX_HEX, + *TemBuffer, + 2 + ); + TemString +=3D StrnLenS (TemString, Length - ((UINTN)TemString -=20 + (UINTN)ValueStr) / sizeof (CHAR16)); } =20 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. =20 -Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.
+Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made availab= le under the terms and conditions of the BSD License which accompanies thi= s distribution. The full @@ -417,14 +417,22 @@ VlanUpdateForm ( // // Pad VlanId string up to 4 characters with space // - DigitalCount =3D UnicodeValueToString (VlanIdStr, 0, VlanData[Index].V= lanId, 5); + UnicodeValueToStringS (VlanIdStr, sizeof (VlanIdStr), 0, VlanData[Inde= x].VlanId, 5); + DigitalCount =3D 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 +=3D 4; =20 StrCpyS (String, (sizeof (VlanStr) /sizeof (CHAR16)) - 10 - (4 - Digi= talCount) - 4, L", Priority:"); String +=3D 11; - String +=3D UnicodeValueToString (String, 0, VlanData[Index].Priority,= 4); + UnicodeValueToStringS ( + String, + sizeof (VlanStr) - ((UINTN)String - (UINTN)VlanStr), + 0, + VlanData[Index].Priority, + 4 + ); + String +=3D StrnLenS (String, ARRAY_SIZE (VlanStr) - ((UINTN)String -= =20 + (UINTN)VlanStr) / sizeof (CHAR16)); *String =3D 0; =20 StringId =3D HiiSetString (PrivateData->HiiHandle, 0, VlanStr, NULL); = diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Expression.c b/MdeModul= ePkg/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. =20 -Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made availab= le under the terms and conditions of the BSD License which accompanies thi= s distribution. The full text of the license may be found at @@ -3143,7 +3= 143,14 @@ EvaluateExpression ( TempBuffer =3D (UINT8 *) &Value->Value + OpCode->ValueWidth - = 1; StrPtr =3D NameValue; for (Index =3D 0; Index < OpCode->ValueWidth; Index ++, TempBu= ffer --) { - StrPtr +=3D UnicodeValueToString (StrPtr, PREFIX_ZERO | RADI= X_HEX, *TempBuffer, 2); + UnicodeValueToStringS ( + StrPtr, + (OpCode->ValueWidth * 2 + 1) * sizeof (CHAR16) - ((UINTN)S= trPtr - (UINTN)NameValue), + PREFIX_ZERO | RADIX_HEX, + *TempBuffer, + 2 + ); + StrPtr +=3D StrnLenS (StrPtr, OpCode->ValueWidth * 2 + 1 -=20 + ((UINTN)StrPtr - (UINTN)NameValue) / sizeof (CHAR16)); } Status =3D SetValueByName (OpCode->VarStorage, OpCode->ValueNa= me, NameValue, GetSetValueWithEditBuffer, NULL); FreePool (NameValue); diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c b/MdeModuleP= kg/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. =20 -Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made availab= le under the terms and conditions of the BSD License which accompanies thi= s distribution. The full text of the license may be found at @@ -116,7 +11= 6,7 @@ UpdateCheckBoxStringToken ( ASSERT (Statement !=3D NULL); ASSERT (Statement->Operand =3D=3D EFI_IFR_NUMERIC_OP); =20 - UnicodeValueToString (Str, 0, Statement->VarStoreInfo.VarName, MAXIMUM_V= ALUE_CHARACTERS - 1); + UnicodeValueToStringS (Str, sizeof (Str), 0,=20 + Statement->VarStoreInfo.VarName, MAXIMUM_VALUE_CHARACTERS - 1); =20 Id =3D HiiSetString (FormSet->HiiHandle, 0, Str, NULL); if (Id =3D=3D 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. =20 -Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made availab= le under the terms and conditions of the BSD License which accompanies thi= s distribution. The full text of the license may be found at @@ -1972,7 +1= 972,14 @@ SetQuestionValue ( TemName =3D (CHAR16 *) Src; TemString =3D Value; for (; *TemName !=3D L'\0'; TemName++) { - TemString +=3D UnicodeValueToString (TemString, PREFIX_ZERO | RA= DIX_HEX, *TemName, 4); + UnicodeValueToStringS ( + TemString, + BufferLen - ((UINTN)TemString - (UINTN)Value), + PREFIX_ZERO | RADIX_HEX, + *TemName, + 4 + ); + TemString +=3D StrnLenS (TemString, (BufferLen -=20 + ((UINTN)TemString - (UINTN)Value)) / sizeof (CHAR16)); } } else { BufferLen =3D StorageWidth * 2 + 1; @@ -1984,7 +1991,14 @@ SetQues= tionValue ( TemBuffer =3D Src + StorageWidth - 1; TemString =3D Value; for (Index =3D 0; Index < StorageWidth; Index ++, TemBuffer --) { - TemString +=3D UnicodeValueToString (TemString, PREFIX_ZERO | RA= DIX_HEX, *TemBuffer, 2); + UnicodeValueToStringS ( + TemString, + BufferLen * sizeof (CHAR16) - ((UINTN)TemString - (UINTN)Value= ), + PREFIX_ZERO | RADIX_HEX, + *TemBuffer, + 2 + ); + TemString +=3D StrnLenS (TemString, BufferLen -=20 + ((UINTN)TemString - (UINTN)Value) / sizeof (CHAR16)); } } =20 @@ -2034,7 +2048,14 @@ SetQuestionValue ( TemName =3D (CHAR16 *) Src; TemString =3D Value; for (; *TemName !=3D L'\0'; TemName++) { - TemString +=3D UnicodeValueToString (TemString, PREFIX_ZERO | RADI= X_HEX, *TemName, 4); + UnicodeValueToStringS ( + TemString, + MaxLen * sizeof (CHAR16) - ((UINTN)TemString - (UINTN)ConfigResp= ), + PREFIX_ZERO | RADIX_HEX, + *TemName, + 4 + ); + TemString +=3D StrnLenS (TemString, MaxLen - ((UINTN)TemString -=20 + (UINTN)ConfigResp) / sizeof (CHAR16)); } } else { // @@ -2043,7 +2064,14 @@ SetQuestionValue ( TemBuffer =3D Src + StorageWidth - 1; TemString =3D Value; for (Index =3D 0; Index < StorageWidth; Index ++, TemBuffer --) { - TemString +=3D UnicodeValueToString (TemString, PREFIX_ZERO | RADI= X_HEX, *TemBuffer, 2); + UnicodeValueToStringS ( + TemString, + MaxLen * sizeof (CHAR16) - ((UINTN)TemString - (UINTN)ConfigResp= ), + PREFIX_ZERO | RADIX_HEX, + *TemBuffer, + 2 + ); + TemString +=3D StrnLenS (TemString, MaxLen - ((UINTN)TemString -=20 + (UINTN)ConfigResp) / sizeof (CHAR16)); } } =20 -- 1.9.5.msysgit.0