From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 5164B82023 for ; Thu, 15 Dec 2016 19:38:41 -0800 (PST) Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga101.fm.intel.com with ESMTP; 15 Dec 2016 19:38:41 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,355,1477983600"; d="scan'208";a="42940870" Received: from shwdeopenpsi014.ccr.corp.intel.com ([10.239.9.34]) by orsmga005.jf.intel.com with ESMTP; 15 Dec 2016 19:38:39 -0800 From: Hao Wu To: edk2-devel@lists.01.org Cc: Hao Wu , Jiewen Yao , Liming Gao , Michael D Kinney Date: Fri, 16 Dec 2016 11:37:39 +0800 Message-Id: <1481859463-10536-3-git-send-email-hao.a.wu@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.0 In-Reply-To: <1481859463-10536-1-git-send-email-hao.a.wu@intel.com> References: <1481859463-10536-1-git-send-email-hao.a.wu@intel.com> Subject: [PATCH v2 2/6] MdePkg/BaseLib: Add an additional check within (Ascii)StrnCmp X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 Dec 2016 03:38:41 -0000 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. Cc: Jiewen Yao Cc: Liming Gao Cc: Michael D Kinney Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Hao Wu Reviewed-by: Michael Kinney --- MdePkg/Library/BaseLib/String.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/MdePkg/Library/BaseLib/String.c b/MdePkg/Library/BaseLib/String.c index 25962f8..fa96d1c 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.
+ Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
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++; -- 1.9.5.msysgit.0