diff options
author | Hao Wu <hao.a.wu@intel.com> | 2016-12-07 10:39:03 +0800 |
---|---|---|
committer | Hao Wu <hao.a.wu@intel.com> | 2016-12-22 16:17:11 +0800 |
commit | 753a18f965cb9cd9e48d376a6c71823548eeb3a0 (patch) | |
tree | c9e73799be9b0082b97af860e10b425952a3363d /MdePkg/Library/BaseLib/String.c | |
parent | c07c517cc51a4f947022aa5eebe2aace326137e5 (diff) | |
download | edk2-753a18f965cb9cd9e48d376a6c71823548eeb3a0.tar.gz edk2-753a18f965cb9cd9e48d376a6c71823548eeb3a0.tar.bz2 edk2-753a18f965cb9cd9e48d376a6c71823548eeb3a0.zip |
MdePkg/BaseLib: Add an additional check within (Ascii)StrnCmp
This commit adds an addtional check in AsciiStrnCmp and StrnCmp. It
explicitly checks the end of the sting pointed by 'SecondString' to make
the code logic easier for reading and to prevent possible mis-reports by
static code checkers.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Michael Kinney <michael.d.kinney@intel.com>
Diffstat (limited to 'MdePkg/Library/BaseLib/String.c')
-rw-r--r-- | MdePkg/Library/BaseLib/String.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/MdePkg/Library/BaseLib/String.c b/MdePkg/Library/BaseLib/String.c index 25962f85b2..fa96d1c1ee 100644 --- a/MdePkg/Library/BaseLib/String.c +++ b/MdePkg/Library/BaseLib/String.c @@ -1,7 +1,7 @@ /** @file
Unicode and ASCII string primitives.
- Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2006 - 2016, 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
@@ -315,6 +315,7 @@ StrnCmp ( }
while ((*FirstString != L'\0') &&
+ (*SecondString != L'\0') &&
(*FirstString == *SecondString) &&
(Length > 1)) {
FirstString++;
@@ -1474,6 +1475,7 @@ AsciiStrnCmp ( }
while ((*FirstString != '\0') &&
+ (*SecondString != '\0') &&
(*FirstString == *SecondString) &&
(Length > 1)) {
FirstString++;
|