PerformancePkg Dp_App: Fix ASSERT in GetNameFromHandle
This commit will resolve the issue brought by r17745. StrCpyS (mGaugeString, DP_GAUGE_STRING_LENGTH + 1, StringPtr); The above using of StrCpyS will cause ASSERT if StringPtr is longer than mGaugeString. Therefore, StrnCpyS is used here to resolve the issue. Similar scenario is for: StrCpyS (mGaugeString, DP_GAUGE_STRING_LENGTH + 1, NameString); (twice) Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Hao Wu <hao.a.wu@intel.com> Reviewed-by: Star Zeng <star.zeng@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17935 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
@ -290,10 +290,11 @@ GetNameFromHandle (
|
|||||||
);
|
);
|
||||||
SafeFreePool (BestLanguage);
|
SafeFreePool (BestLanguage);
|
||||||
if (!EFI_ERROR (Status)) {
|
if (!EFI_ERROR (Status)) {
|
||||||
StrCpyS (
|
StrnCpyS (
|
||||||
mGaugeString,
|
mGaugeString,
|
||||||
DP_GAUGE_STRING_LENGTH + 1,
|
DP_GAUGE_STRING_LENGTH + 1,
|
||||||
StringPtr
|
StringPtr,
|
||||||
|
DP_GAUGE_STRING_LENGTH
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -337,10 +338,11 @@ GetNameFromHandle (
|
|||||||
//
|
//
|
||||||
// Method 3. Get the name string from FFS UI section
|
// Method 3. Get the name string from FFS UI section
|
||||||
//
|
//
|
||||||
StrCpyS (
|
StrnCpyS (
|
||||||
mGaugeString,
|
mGaugeString,
|
||||||
DP_GAUGE_STRING_LENGTH + 1,
|
DP_GAUGE_STRING_LENGTH + 1,
|
||||||
NameString
|
NameString,
|
||||||
|
DP_GAUGE_STRING_LENGTH
|
||||||
);
|
);
|
||||||
FreePool (NameString);
|
FreePool (NameString);
|
||||||
} else {
|
} else {
|
||||||
@ -356,10 +358,11 @@ GetNameFromHandle (
|
|||||||
//
|
//
|
||||||
NameString = ConvertDevicePathToText (LoadedImageDevicePath, TRUE, FALSE);
|
NameString = ConvertDevicePathToText (LoadedImageDevicePath, TRUE, FALSE);
|
||||||
if (NameString != NULL) {
|
if (NameString != NULL) {
|
||||||
StrCpyS (
|
StrnCpyS (
|
||||||
mGaugeString,
|
mGaugeString,
|
||||||
DP_GAUGE_STRING_LENGTH + 1,
|
DP_GAUGE_STRING_LENGTH + 1,
|
||||||
NameString
|
NameString,
|
||||||
|
DP_GAUGE_STRING_LENGTH
|
||||||
);
|
);
|
||||||
FreePool (NameString);
|
FreePool (NameString);
|
||||||
return;
|
return;
|
||||||
|
Reference in New Issue
Block a user