Discussion:
[edk2] [PATCH 11/13] MdeModulePkg/Universal/PlatformDriOverrideDxe: Use safe string functions to refine code.
Qiu Shumin
2015-06-25 07:47:05 UTC
Permalink
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Qiu Shumin <***@intel.com>
---
.../Universal/PlatformDriOverrideDxe/PlatDriOverrideDxe.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/MdeModulePkg/Universal/PlatformDriOverrideDxe/PlatDriOverrideDxe.c b/MdeModulePkg/Universal/PlatformDriOverrideDxe/PlatDriOverrideDxe.c
index 7027e96..a232b21 100644
--- a/MdeModulePkg/Universal/PlatformDriOverrideDxe/PlatDriOverrideDxe.c
+++ b/MdeModulePkg/Universal/PlatformDriOverrideDxe/PlatDriOverrideDxe.c
@@ -492,11 +492,11 @@ UpdateDeviceSelectPage (
NewString = AllocateZeroPool (Len + StrSize (L"--"));
ASSERT (NewString != NULL);
if (EFI_ERROR (CheckMapping (ControllerDevicePath,NULL, &mMappingDataBase, NULL, NULL))) {
- StrCat (NewString, L"--");
+ StrCatS (NewString, (Len + StrSize (L"--"))/sizeof(CHAR16), L"--");
} else {
- StrCat (NewString, L"**");
+ StrCatS (NewString, (Len + StrSize (L"--"))/sizeof(CHAR16), L"**");
}
- StrCat (NewString, ControllerName);
+ StrCatS (NewString, (Len + StrSize (L"--"))/sizeof(CHAR16), ControllerName);

NewStringToken = HiiSetString (Private->RegisteredHandle, mControllerToken[Index], NewString, NULL);
ASSERT (NewStringToken != 0);
@@ -822,7 +822,7 @@ UpdateBindingDriverSelectPage (
mDriSelection[Index] = TRUE;
mLastSavedDriverImageNum++;
}
- StrCat (NewString, DriverName);
+ StrCatS (NewString, StrSize (DriverName)/sizeof(CHAR16), DriverName);
NewStringToken = HiiSetString (Private->RegisteredHandle, mDriverImageToken[Index], NewString, NULL);
ASSERT (NewStringToken != 0);
mDriverImageToken[Index] = NewStringToken;
@@ -838,7 +838,7 @@ UpdateBindingDriverSelectPage (

NewString = AllocateZeroPool (StrSize (DriverName));
ASSERT (NewString != NULL);
- StrCat (NewString, DriverName);
+ StrCatS (NewString, StrSize (DriverName)/sizeof(CHAR16), DriverName);
NewStringHelpToken = HiiSetString (Private->RegisteredHandle, DriverImageFilePathToken[Index], NewString, NULL);
ASSERT (NewStringHelpToken != 0);
DriverImageFilePathToken[Index] = NewStringHelpToken;
--
1.9.5.msysgit.1
Gao, Liming
2015-06-29 08:57:43 UTC
Permalink
Shumin:
How about use one local variable to cache size, then use it in the below reference?

Thanks
Liming
-----Original Message-----
From: Qiu, Shumin
Sent: Thursday, June 25, 2015 3:47 PM
To: edk2-***@lists.sourceforge.net
Cc: Zeng, Star; Fan, Jeff; Gao, Liming; Ni, Ruiyu; Tian, Feng
Subject: [PATCH 11/13] MdeModulePkg/Universal/PlatformDriOverrideDxe: Use safe string functions to refine code.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Qiu Shumin <***@intel.com>
---
.../Universal/PlatformDriOverrideDxe/PlatDriOverrideDxe.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/MdeModulePkg/Universal/PlatformDriOverrideDxe/PlatDriOverrideDxe.c b/MdeModulePkg/Universal/PlatformDriOverrideDxe/PlatDriOverrideDxe.c
index 7027e96..a232b21 100644
--- a/MdeModulePkg/Universal/PlatformDriOverrideDxe/PlatDriOverrideDxe.c
+++ b/MdeModulePkg/Universal/PlatformDriOverrideDxe/PlatDriOverrideDxe.c
@@ -492,11 +492,11 @@ UpdateDeviceSelectPage (
NewString = AllocateZeroPool (Len + StrSize (L"--"));
ASSERT (NewString != NULL);
if (EFI_ERROR (CheckMapping (ControllerDevicePath,NULL, &mMappingDataBase, NULL, NULL))) {
- StrCat (NewString, L"--");
+ StrCatS (NewString, (Len + StrSize (L"--"))/sizeof(CHAR16),
+ L"--");
} else {
- StrCat (NewString, L"**");
+ StrCatS (NewString, (Len + StrSize (L"--"))/sizeof(CHAR16),
+ L"**");
}
- StrCat (NewString, ControllerName);
+ StrCatS (NewString, (Len + StrSize (L"--"))/sizeof(CHAR16),
+ ControllerName);

NewStringToken = HiiSetString (Private->RegisteredHandle, mControllerToken[Index], NewString, NULL);
ASSERT (NewStringToken != 0);
@@ -822,7 +822,7 @@ UpdateBindingDriverSelectPage (
mDriSelection[Index] = TRUE;
mLastSavedDriverImageNum++;
}
- StrCat (NewString, DriverName);
+ StrCatS (NewString, StrSize (DriverName)/sizeof(CHAR16),
+ DriverName);
NewStringToken = HiiSetString (Private->RegisteredHandle, mDriverImageToken[Index], NewString, NULL);
ASSERT (NewStringToken != 0);
mDriverImageToken[Index] = NewStringToken; @@ -838,7 +838,7 @@ UpdateBindingDriverSelectPage (

NewString = AllocateZeroPool (StrSize (DriverName));
ASSERT (NewString != NULL);
- StrCat (NewString, DriverName);
+ StrCatS (NewString, StrSize (DriverName)/sizeof(CHAR16),
+ DriverName);
NewStringHelpToken = HiiSetString (Private->RegisteredHandle, DriverImageFilePathToken[Index], NewString, NULL);
ASSERT (NewStringHelpToken != 0);
DriverImageFilePathToken[Index] = NewStringHelpToken;
--
1.9.5.msysgit.1

Loading...