From e75390f02971bcd4d67a9696508050bee4936a01 Mon Sep 17 00:00:00 2001 From: Qiu Shumin Date: Tue, 30 Jun 2015 03:18:31 +0000 Subject: ShellPkg: Use safe string functions to refine code. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Qiu Shumin Reviewed-by: Jaben Carsey Reviewed-by: Star Zeng git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17730 6f19259b-4bc3-4df7-8a09-765794883524 --- ShellPkg/Library/UefiDpLib/DpUtilities.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'ShellPkg/Library/UefiDpLib') diff --git a/ShellPkg/Library/UefiDpLib/DpUtilities.c b/ShellPkg/Library/UefiDpLib/DpUtilities.c index ef204ffef1..7290285e23 100644 --- a/ShellPkg/Library/UefiDpLib/DpUtilities.c +++ b/ShellPkg/Library/UefiDpLib/DpUtilities.c @@ -1,7 +1,7 @@ /** @file Utility functions used by the Dp application. - Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved. + Copyright (c) 2009 - 2015, 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 @@ -141,10 +141,10 @@ GetShortPdbFileName ( UINTN StartIndex; UINTN EndIndex; - ZeroMem (UnicodeBuffer, DXE_PERFORMANCE_STRING_LENGTH * sizeof (CHAR16)); + ZeroMem (UnicodeBuffer, (DP_GAUGE_STRING_LENGTH + 1) * sizeof (CHAR16)); if (PdbFileName == NULL) { - StrnCpy (UnicodeBuffer, L" ", 1); + StrnCpyS (UnicodeBuffer, DP_GAUGE_STRING_LENGTH + 1, L" ", 1); } else { StartIndex = 0; for (EndIndex = 0; PdbFileName[EndIndex] != 0; EndIndex++) @@ -261,7 +261,7 @@ GetNameFromHandle ( ); if (!EFI_ERROR (Status)) { SHELL_FREE_NON_NULL (PlatformLanguage); - StrnCpy (mGaugeString, StringPtr, DP_GAUGE_STRING_LENGTH); + StrCpyS (mGaugeString, DP_GAUGE_STRING_LENGTH + 1, StringPtr); mGaugeString[DP_GAUGE_STRING_LENGTH] = 0; return; } @@ -305,7 +305,7 @@ GetNameFromHandle ( // // Method 3. Get the name string from FFS UI section // - StrnCpy (mGaugeString, NameString, DP_GAUGE_STRING_LENGTH); + StrCpyS (mGaugeString, DP_GAUGE_STRING_LENGTH + 1, NameString); mGaugeString[DP_GAUGE_STRING_LENGTH] = 0; FreePool (NameString); } else { @@ -321,7 +321,7 @@ GetNameFromHandle ( // NameString = ConvertDevicePathToText (LoadedImageDevicePath, TRUE, FALSE); if (NameString != NULL) { - StrnCpy (mGaugeString, NameString, DP_GAUGE_STRING_LENGTH); + StrCpyS (mGaugeString, DP_GAUGE_STRING_LENGTH + 1, NameString); mGaugeString[DP_GAUGE_STRING_LENGTH] = 0; FreePool (NameString); return; @@ -334,7 +334,7 @@ GetNameFromHandle ( // StringPtr = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_DP_ERROR_NAME), NULL); ASSERT (StringPtr != NULL); - StrnCpy (mGaugeString, StringPtr, DP_GAUGE_STRING_LENGTH); + StrCpyS (mGaugeString, DP_GAUGE_STRING_LENGTH + 1, StringPtr); FreePool (StringPtr); } -- cgit v1.2.3