public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Michael D Kinney <michael.d.kinney@intel.com>
To: edk2-devel@lists.01.org
Cc: Andrew Fish <afish@apple.com>,
	Michael Kinney <michael.d.kinney@intel.com>,
	Felix Polyudov <felixp@ami.com>
Subject: [edk2-staging/edk2-test Patch V2 2/2] TestFrameworkPkg/TestProfile: Fix overlapping buffer ASSERT()
Date: Mon, 14 Aug 2017 20:57:18 -0700	[thread overview]
Message-ID: <20170815035718.1560-3-michael.d.kinney@intel.com> (raw)
In-Reply-To: <20170815035718.1560-1-michael.d.kinney@intel.com>

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



  parent reply	other threads:[~2017-08-15  3:54 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-15  3:57 [edk2-staging/edk2-test Patch V2 0/2] TestFrameworkPkg/TestProfile: Fix overlapping buffer ASSERT() Michael D Kinney
2017-08-15  3:57 ` [edk2-staging/edk2-test Patch V2 1/2] Test*Pkg: Update DSC files to improve debug Michael D Kinney
2017-08-15  3:57 ` Michael D Kinney [this message]
2017-08-17  3:16 ` [edk2-staging/edk2-test Patch V2 0/2] TestFrameworkPkg/TestProfile: Fix overlapping buffer ASSERT() Felix Poludov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170815035718.1560-3-michael.d.kinney@intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox