From dbcecd5da2a76f069f769feb8d875149078c0ab1 Mon Sep 17 00:00:00 2001 From: erictian Date: Wed, 29 Aug 2012 09:23:34 +0000 Subject: [PATCH] Should pass in bytes of string buffer to UnicodeSPrint() rather than Unicode string length. Signed-off-by: Tian Feng Reviewed-by: Liming Gao git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13691 6f19259b-4bc3-4df7-8a09-765794883524 --- .../Universal/BdsDxe/BootMaint/UpdatePage.c | 4 ++-- MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfig.c | 10 +++++----- MdeModulePkg/Universal/SetupBrowserDxe/Expression.c | 2 +- MdePkg/Library/UefiDebugLibConOut/DebugLib.c | 4 ++-- MdePkg/Library/UefiDebugLibStdErr/DebugLib.c | 4 ++-- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/UpdatePage.c b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/UpdatePage.c index 7d4f33d409..7317767c00 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 - 2011, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2012, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -1191,7 +1191,7 @@ GetLegacyBootOptionVar ( } for (Index = 0; Index < OrderSize / sizeof (UINT16); Index++) { - UnicodeSPrint (StrTemp, 100, L"Boot%04x", OrderBuffer[Index]); + UnicodeSPrint (StrTemp, sizeof (StrTemp), L"Boot%04x", OrderBuffer[Index]); OptionBuffer = BdsLibGetVariableAndSize ( StrTemp, &gEfiGlobalVariableGuid, diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfig.c b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfig.c index 74ab8b8ed7..702f4f43cf 100644 --- a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfig.c +++ b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfig.c @@ -1,7 +1,7 @@ /** @file Helper functions for configuring or getting the parameters relating to iSCSI. -Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2012, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -94,7 +94,7 @@ IScsiParseIsIdFromString ( if (StrLen (IsIdStr) != 6) { UnicodeSPrint ( PortString, - (UINTN) ISCSI_NAME_IFR_MAX_SIZE, + (UINTN) sizeof (PortString), L"Error! Input is incorrect, please input 6 hex numbers!\n" ); @@ -700,7 +700,7 @@ IScsiFormCallback ( ConfigFormEntry = IScsiGetConfigFormEntryByIndex ((UINT32) (QuestionId - KEY_DEVICE_ENTRY_BASE)); ASSERT (ConfigFormEntry != NULL); - UnicodeSPrint (PortString, (UINTN) 128, L"Port %s", ConfigFormEntry->MacString); + UnicodeSPrint (PortString, (UINTN) sizeof (PortString), L"Port %s", ConfigFormEntry->MacString); DeviceFormTitleToken = (EFI_STRING_ID) STR_ISCSI_DEVICE_FORM_TITLE; HiiSetString (Private->RegisteredHandle, DeviceFormTitleToken, PortString, NULL); @@ -1034,13 +1034,13 @@ IScsiConfigUpdateForm ( // // Compose the Port string and create a new EFI_STRING_ID. // - UnicodeSPrint (PortString, 128, L"Port %s", ConfigFormEntry->MacString); + UnicodeSPrint (PortString, sizeof (PortString), L"Port %s", ConfigFormEntry->MacString); ConfigFormEntry->PortTitleToken = HiiSetString (mCallbackInfo->RegisteredHandle, 0, PortString, NULL); // // Compose the help string of this port and create a new EFI_STRING_ID. // - UnicodeSPrint (PortString, 128, L"Set the iSCSI parameters on port %s", ConfigFormEntry->MacString); + UnicodeSPrint (PortString, sizeof (PortString), L"Set the iSCSI parameters on port %s", ConfigFormEntry->MacString); ConfigFormEntry->PortTitleHelpToken = HiiSetString (mCallbackInfo->RegisteredHandle, 0, PortString, NULL); InsertTailList (&mIScsiConfigFormList, &ConfigFormEntry->Link); diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Expression.c b/MdeModulePkg/Universal/SetupBrowserDxe/Expression.c index 27be635e9c..1a47f2b0a9 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/Expression.c +++ b/MdeModulePkg/Universal/SetupBrowserDxe/Expression.c @@ -1071,7 +1071,7 @@ IfrToString ( CopyMem (TmpBuf, Value.Buffer, Value.BufferLen * sizeof (CHAR16)); PrintFormat = L"%s"; } - UnicodeSPrint (Buffer, MAXIMUM_VALUE_CHARACTERS, PrintFormat, Value.Buffer); + UnicodeSPrint (Buffer, sizeof (Buffer), PrintFormat, Value.Buffer); String = Buffer; FreePool (TmpBuf); FreePool (Value.Buffer); diff --git a/MdePkg/Library/UefiDebugLibConOut/DebugLib.c b/MdePkg/Library/UefiDebugLibConOut/DebugLib.c index ce4b32426d..e0ac471f95 100644 --- a/MdePkg/Library/UefiDebugLibConOut/DebugLib.c +++ b/MdePkg/Library/UefiDebugLibConOut/DebugLib.c @@ -1,7 +1,7 @@ /** @file UEFI Debug Library that sends messages to the Console Output Device in the EFI System Table. - Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.
+ Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -120,7 +120,7 @@ DebugAssert ( // UnicodeSPrintAsciiFormat ( Buffer, - MAX_DEBUG_MESSAGE_LENGTH, + sizeof (Buffer), "ASSERT %a(%d): %a\n", FileName, LineNumber, diff --git a/MdePkg/Library/UefiDebugLibStdErr/DebugLib.c b/MdePkg/Library/UefiDebugLibStdErr/DebugLib.c index 73c720497c..a0aa873a4e 100644 --- a/MdePkg/Library/UefiDebugLibStdErr/DebugLib.c +++ b/MdePkg/Library/UefiDebugLibStdErr/DebugLib.c @@ -1,7 +1,7 @@ /** @file UEFI Debug Lib that sends messages to the Standard Error Device in the EFI System Table. - Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.
+ Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -121,7 +121,7 @@ DebugAssert ( // UnicodeSPrintAsciiFormat ( Buffer, - MAX_DEBUG_MESSAGE_LENGTH, + sizeof (Buffer), "ASSERT %a(%d): %a\n", FileName, LineNumber, -- 2.39.2