Discussion:
[edk2] [PATCH] MdeModulePkg: Use StrnCpyS instead of StrCpyS to indicate the copy length from the source.
Qiu Shumin
2015-07-07 02:13:58 UTC
Permalink
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Qiu Shumin <***@intel.com>
Reviewed-by: Hao Wu <***@intel.com>
CC: Liming Gao <***@intel.com>
---
MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c | 4 ++--
MdeModulePkg/Library/UefiBootManagerLib/BmPerformance.c | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c
index 7ebdb29..0eb8e57 100644
--- a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c
+++ b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c
@@ -191,10 +191,10 @@ StartGaugeEx (
GaugeEntryExArray[Index].Handle = (EFI_PHYSICAL_ADDRESS) (UINTN) Handle;

if (Token != NULL) {
- AsciiStrCpyS (GaugeEntryExArray[Index].Token, DXE_PERFORMANCE_STRING_SIZE, Token);
+ AsciiStrnCpyS (GaugeEntryExArray[Index].Token, DXE_PERFORMANCE_STRING_SIZE, Token, DXE_PERFORMANCE_STRING_LENGTH);
}
if (Module != NULL) {
- AsciiStrCpyS (GaugeEntryExArray[Index].Module, DXE_PERFORMANCE_STRING_SIZE, Module);
+ AsciiStrnCpyS (GaugeEntryExArray[Index].Module, DXE_PERFORMANCE_STRING_SIZE, Module, DXE_PERFORMANCE_STRING_LENGTH);
}

GaugeEntryExArray[Index].EndTimeStamp = 0;
diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmPerformance.c b/MdeModulePkg/Library/UefiBootManagerLib/BmPerformance.c
index dd937a7..7b13ec6 100644
--- a/MdeModulePkg/Library/UefiBootManagerLib/BmPerformance.c
+++ b/MdeModulePkg/Library/UefiBootManagerLib/BmPerformance.c
@@ -320,7 +320,7 @@ BmWriteBootToOsPerformanceData (

ZeroMem (&mBmPerfData, sizeof (PERF_DATA));

- AsciiStrCpyS (mBmPerfData.Token, PERF_TOKEN_SIZE, Token);
+ AsciiStrnCpyS (mBmPerfData.Token, PERF_TOKEN_SIZE, Token, PERF_TOKEN_LENGTH);
if (StartTicker == 1) {
StartTicker = StartValue;
}
--
1.9.5.msysgit.1
Gao, Liming
2015-07-07 02:46:31 UTC
Permalink
Reviewed-by: Liming Gao <***@intel.com>

-----Original Message-----
From: Qiu, Shumin
Sent: Tuesday, July 07, 2015 10:14 AM
To: edk2-***@lists.sourceforge.net
Cc: Qiu, Shumin; Gao, Liming
Subject: [edk2][PATCH] MdeModulePkg: Use StrnCpyS instead of StrCpyS to indicate the copy length from the source.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Qiu Shumin <***@intel.com>
Reviewed-by: Hao Wu <***@intel.com>
CC: Liming Gao <***@intel.com>
---
MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c | 4 ++--
MdeModulePkg/Library/UefiBootManagerLib/BmPerformance.c | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c
index 7ebdb29..0eb8e57 100644
--- a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c
+++ b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c
@@ -191,10 +191,10 @@ StartGaugeEx (
GaugeEntryExArray[Index].Handle = (EFI_PHYSICAL_ADDRESS) (UINTN) Handle;

if (Token != NULL) {
- AsciiStrCpyS (GaugeEntryExArray[Index].Token, DXE_PERFORMANCE_STRING_SIZE, Token);
+ AsciiStrnCpyS (GaugeEntryExArray[Index].Token,
+ DXE_PERFORMANCE_STRING_SIZE, Token, DXE_PERFORMANCE_STRING_LENGTH);
}
if (Module != NULL) {
- AsciiStrCpyS (GaugeEntryExArray[Index].Module, DXE_PERFORMANCE_STRING_SIZE, Module);
+ AsciiStrnCpyS (GaugeEntryExArray[Index].Module,
+ DXE_PERFORMANCE_STRING_SIZE, Module, DXE_PERFORMANCE_STRING_LENGTH);
}

GaugeEntryExArray[Index].EndTimeStamp = 0; diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmPerformance.c b/MdeModulePkg/Library/UefiBootManagerLib/BmPerformance.c
index dd937a7..7b13ec6 100644
--- a/MdeModulePkg/Library/UefiBootManagerLib/BmPerformance.c
+++ b/MdeModulePkg/Library/UefiBootManagerLib/BmPerformance.c
@@ -320,7 +320,7 @@ BmWriteBootToOsPerformanceData (

ZeroMem (&mBmPerfData, sizeof (PERF_DATA));

- AsciiStrCpyS (mBmPerfData.Token, PERF_TOKEN_SIZE, Token);
+ AsciiStrnCpyS (mBmPerfData.Token, PERF_TOKEN_SIZE, Token,
+ PERF_TOKEN_LENGTH);
if (StartTicker == 1) {
StartTicker = StartValue;
}
--
1.9.5.msysgit.1

Loading...