diff options
author | Star Zeng <star.zeng@intel.com> | 2014-07-21 03:05:20 +0000 |
---|---|---|
committer | lzeng14 <lzeng14@6f19259b-4bc3-4df7-8a09-765794883524> | 2014-07-21 03:05:20 +0000 |
commit | d52b9d864efb0ba4b812538c45aef0b617bace39 (patch) | |
tree | 872fc62ab692a4eebc9444040dd84ec0ff9bb285 | |
parent | dfa51bb619b455315a0476d0f2335da41268a2a2 (diff) | |
download | edk2-d52b9d864efb0ba4b812538c45aef0b617bace39.zip edk2-d52b9d864efb0ba4b812538c45aef0b617bace39.tar.gz edk2-d52b9d864efb0ba4b812538c45aef0b617bace39.tar.bz2 |
MdePkg BaseLib: Fix a corner case of Source and Destination overlap.
The overlap may happen when the address of Destination in
UnicodeStrToAsciiStr() or Source in AsciiStrToUnicodeStr()
is not two bytes aligned.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15665 6f19259b-4bc3-4df7-8a09-765794883524
-rw-r--r-- | MdePkg/Library/BaseLib/String.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/MdePkg/Library/BaseLib/String.c b/MdePkg/Library/BaseLib/String.c index 227a0dc..9505c5b 100644 --- a/MdePkg/Library/BaseLib/String.c +++ b/MdePkg/Library/BaseLib/String.c @@ -1,7 +1,7 @@ /** @file
Unicode and ASCII string primatives.
- Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -1040,7 +1040,7 @@ UnicodeStrToAsciiStr ( //
// Source and Destination should not overlap
//
- ASSERT ((UINTN) ((CHAR16 *) Destination - Source) > StrLen (Source));
+ ASSERT ((UINTN) (Destination - (CHAR8 *) Source) >= StrSize (Source));
ASSERT ((UINTN) ((CHAR8 *) Source - Destination) > StrLen (Source));
@@ -2008,9 +2008,9 @@ AsciiStrToUnicodeStr ( // Source and Destination should not overlap
//
ASSERT ((UINTN) ((CHAR8 *) Destination - Source) > AsciiStrLen (Source));
- ASSERT ((UINTN) (Source - (CHAR8 *) Destination) > (AsciiStrLen (Source) * sizeof (CHAR16)));
+ ASSERT ((UINTN) (Source - (CHAR8 *) Destination) >= (AsciiStrSize (Source) * sizeof (CHAR16)));
+
-
ReturnValue = Destination;
while (*Source != '\0') {
*(Destination++) = (CHAR16) *(Source++);
|