From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (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 D161581FB4 for ; Mon, 13 Feb 2017 18:41:34 -0800 (PST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Feb 2017 18:41:34 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.35,159,1484035200"; d="scan'208";a="1107022825" Received: from shwdeopenpsi014.ccr.corp.intel.com ([10.239.9.13]) by fmsmga001.fm.intel.com with ESMTP; 13 Feb 2017 18:41:32 -0800 From: Hao Wu To: edk2-devel@lists.01.org Cc: Hao Wu , Jiewen Yao , Liming Gao , Michael Kinney Date: Tue, 14 Feb 2017 10:41:31 +0800 Message-Id: <1487040091-44960-1-git-send-email-hao.a.wu@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.0 Subject: [PATCH v2] MdePkg/BaseLib: Refine logic for (Ascii)StrnLenS to handle MaxSize = 0 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: Tue, 14 Feb 2017 02:41:35 -0000 https://bugzilla.tianocore.org/show_bug.cgi?id=378 Cc: Jiewen Yao Cc: Liming Gao Cc: Michael Kinney Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Hao Wu --- MdePkg/Library/BaseLib/SafeString.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/MdePkg/Library/BaseLib/SafeString.c b/MdePkg/Library/BaseLib/SafeString.c index 315059e..79c79e0 100644 --- a/MdePkg/Library/BaseLib/SafeString.c +++ b/MdePkg/Library/BaseLib/SafeString.c @@ -128,9 +128,9 @@ StrnLenS ( ASSERT (((UINTN) String & BIT0) == 0); // - // If String is a null pointer, then the StrnLenS function returns zero. + // If String is a null pointer or MaxSize is 0, then the StrnLenS function returns zero. // - if (String == NULL) { + if ((String == NULL) || (MaxSize == 0)) { return 0; } @@ -1097,9 +1097,9 @@ AsciiStrnLenS ( UINTN Length; // - // If String is a null pointer, then the AsciiStrnLenS function returns zero. + // If String is a null pointer or MaxSize is 0, then the AsciiStrnLenS function returns zero. // - if (String == NULL) { + if ((String == NULL) || (MaxSize == 0)) { return 0; } -- 1.9.5.msysgit.0