]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdePkg/BaseLib: Add an additional check within (Ascii)StrnCmp
authorHao Wu <hao.a.wu@intel.com>
Wed, 7 Dec 2016 02:39:03 +0000 (10:39 +0800)
committerHao Wu <hao.a.wu@intel.com>
Thu, 22 Dec 2016 08:17:11 +0000 (16:17 +0800)
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>
MdePkg/Library/BaseLib/String.c

index 25962f85b25ca085bae8e72d0a24c5f54fe7a8fd..fa96d1c1eec8ceedd3f7bc0da8f31e839ce0b675 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Unicode and ASCII string primitives.\r
 \r
-  Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -315,6 +315,7 @@ StrnCmp (
   }\r
 \r
   while ((*FirstString != L'\0') &&\r
+         (*SecondString != L'\0') &&\r
          (*FirstString == *SecondString) &&\r
          (Length > 1)) {\r
     FirstString++;\r
@@ -1474,6 +1475,7 @@ AsciiStrnCmp (
   }\r
 \r
   while ((*FirstString != '\0') &&\r
+         (*SecondString != '\0') &&\r
          (*FirstString == *SecondString) &&\r
          (Length > 1)) {\r
     FirstString++;\r