[edk2] [edk2-staging/edk2-test Patch V2 2/2] TestFrameworkPkg/TestProfile: Fix overlapping buffer ASSERT()

Michael D Kinney posted 2 patches 7 years, 4 months ago
[edk2] [edk2-staging/edk2-test Patch V2 2/2] TestFrameworkPkg/TestProfile: Fix overlapping buffer ASSERT()
Posted by Michael D Kinney 7 years, 4 months ago
The patch is a bug fix for TestFrameworkPkg/Support/TestProfile
driver. AsciiStrCpy() function was used to copy overlapping
strings, which triggered an ASSERT().

The function was used on overlapping strings in a couple of places:
1. _alltrim(): AsciiStrCpy() is replaced with CopyMem(), which can
   handle overlapping buffers.
2. _prosessLine(): AsciiStrCpy() at the beginning of the function
   is removed. The call was redundant. The function was trying to
   move the data that have already been moved by _alltrim().

Cc: Andrew Fish <afish@apple.com>
Cc: Michael Kinney <michael.d.kinney@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Felix Polyudov <felixp@ami.com>
---
 TestFrameworkPkg/Support/TestProfile/TestProfile.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/TestFrameworkPkg/Support/TestProfile/TestProfile.c b/TestFrameworkPkg/Support/TestProfile/TestProfile.c
index f02e9dfef..2476c5740 100644
--- a/TestFrameworkPkg/Support/TestProfile/TestProfile.c
+++ b/TestFrameworkPkg/Support/TestProfile/TestProfile.c
@@ -269,7 +269,7 @@ Routine Description:
   }
 
   tmp[Index] = '\0';
-  AsciiStrCpy (ptrStr, tmp);
+  CopyMem(ptrStr, tmp, Index + 1);
 
   return ptrStr;
 }
@@ -419,7 +419,7 @@ Routine Description:
   CHAR8 ptrValue[MAX_STRING_LEN + 1];
   INI   *ptrItem;
 
-  AsciiStrCpy (ptrLine, _alltrim (ptrLine));
+  _alltrim (ptrLine);
 
   if (*ptrLine == '#') {
     // it's a comment line
-- 
2.13.1.windows.2

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel