summaryrefslogtreecommitdiff
path: root/MdeModulePkg/Library/UefiBootManagerLib/BmPerformance.c
diff options
context:
space:
mode:
authorQiu Shumin <shumin.qiu@intel.com>2015-07-01 08:21:16 +0000
committershenshushi <shenshushi@Edk2>2015-07-01 08:21:16 +0000
commitb6344b37c98a78c2a9f3b8522eb2ccbda22bc573 (patch)
tree4882c73f8395400c15242e52f0259684cd8c5851 /MdeModulePkg/Library/UefiBootManagerLib/BmPerformance.c
parent93fd37dc0be4ecc4ba572ebac07ec3f0e3d86cfa (diff)
downloadedk2-platforms-b6344b37c98a78c2a9f3b8522eb2ccbda22bc573.tar.xz
MdeModulePkg/Library/UefiBootManagerLib: Use safe string functions to refine code.
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Qiu Shumin <shumin.qiu@intel.com> Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17782 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdeModulePkg/Library/UefiBootManagerLib/BmPerformance.c')
-rw-r--r--MdeModulePkg/Library/UefiBootManagerLib/BmPerformance.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmPerformance.c b/MdeModulePkg/Library/UefiBootManagerLib/BmPerformance.c
index 32229d0b0a..dd937a7396 100644
--- a/MdeModulePkg/Library/UefiBootManagerLib/BmPerformance.c
+++ b/MdeModulePkg/Library/UefiBootManagerLib/BmPerformance.c
@@ -26,12 +26,14 @@ EFI_PHYSICAL_ADDRESS mBmAcpiLowMemoryBase = 0x0FFFFFFFFULL;
@param PdbFileName The long PDB file name.
@param GaugeString The output string to be logged by performance logger.
+ @param StringSize The buffer size of GaugeString in bytes.
**/
VOID
BmGetShortPdbFileName (
IN CONST CHAR8 *PdbFileName,
- OUT CHAR8 *GaugeString
+ OUT CHAR8 *GaugeString,
+ IN UINTN StringSize
)
{
UINTN Index;
@@ -40,7 +42,7 @@ BmGetShortPdbFileName (
UINTN EndIndex;
if (PdbFileName == NULL) {
- AsciiStrCpy (GaugeString, " ");
+ AsciiStrCpyS (GaugeString, StringSize, " ");
} else {
StartIndex = 0;
for (EndIndex = 0; PdbFileName[EndIndex] != 0; EndIndex++)
@@ -78,12 +80,14 @@ BmGetShortPdbFileName (
@param Handle Driver handle.
@param GaugeString The output string to be logged by performance logger.
+ @param StringSize The buffer size of GaugeString in bytes.
**/
VOID
BmGetNameFromHandle (
IN EFI_HANDLE Handle,
- OUT CHAR8 *GaugeString
+ OUT CHAR8 *GaugeString,
+ IN UINTN StringSize
)
{
EFI_STATUS Status;
@@ -91,7 +95,7 @@ BmGetNameFromHandle (
CHAR8 *PdbFileName;
EFI_DRIVER_BINDING_PROTOCOL *DriverBinding;
- AsciiStrCpy (GaugeString, " ");
+ AsciiStrCpyS (GaugeString, StringSize, " ");
//
// Get handle name from image protocol
@@ -127,7 +131,7 @@ BmGetNameFromHandle (
PdbFileName = PeCoffLoaderGetPdbPointer (Image->ImageBase);
if (PdbFileName != NULL) {
- BmGetShortPdbFileName (PdbFileName, GaugeString);
+ BmGetShortPdbFileName (PdbFileName, GaugeString, StringSize);
}
return ;
@@ -285,9 +289,9 @@ BmWriteBootToOsPerformanceData (
if (Duration > 0) {
- BmGetNameFromHandle (Handles[Index], GaugeString);
+ BmGetNameFromHandle (Handles[Index], GaugeString, PERF_TOKEN_LENGTH);
- AsciiStrCpy (mBmPerfData.Token, GaugeString);
+ AsciiStrCpyS (mBmPerfData.Token, PERF_TOKEN_SIZE, GaugeString);
mBmPerfData.Duration = Duration;
CopyMem (Ptr, &mBmPerfData, sizeof (PERF_DATA));
@@ -316,7 +320,7 @@ BmWriteBootToOsPerformanceData (
ZeroMem (&mBmPerfData, sizeof (PERF_DATA));
- AsciiStrnCpy (mBmPerfData.Token, Token, PERF_TOKEN_LENGTH);
+ AsciiStrCpyS (mBmPerfData.Token, PERF_TOKEN_SIZE, Token);
if (StartTicker == 1) {
StartTicker = StartValue;
}