From nobody Sat Nov 2 14:22:51 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zoho.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1487040168220978.3499390352782; Mon, 13 Feb 2017 18:42:48 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 1798D81FBC; Mon, 13 Feb 2017 18:42:47 -0800 (PST) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (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 59FC781FB4 for ; Mon, 13 Feb 2017 18:42:45 -0800 (PST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga105.fm.intel.com with ESMTP; 13 Feb 2017 18:42:45 -0800 Received: from shwdeopenpsi014.ccr.corp.intel.com ([10.239.9.13]) by fmsmga001.fm.intel.com with ESMTP; 13 Feb 2017 18:42:43 -0800 X-Original-To: edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.35,159,1484035200"; d="scan'208";a="1107023057" From: Hao Wu To: edk2-devel@lists.01.org Date: Tue, 14 Feb 2017 10:42:41 +0800 Message-Id: <1487040161-5056-1-git-send-email-hao.a.wu@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.0 Subject: [edk2] [PATCH] 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: , Cc: Hao Wu , Michael Kinney , Jiewen Yao , Liming Gao MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" https://bugzilla.tianocore.org/show_bug.cgi?id=3D378 Cc: Jiewen Yao Cc: Liming Gao Cc: Michael Kinney Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Hao Wu Reviewed-by: jiewen.yao@intel.com --- 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/S= afeString.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) =3D=3D 0); =20 // - // 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 functi= on returns zero. // - if (String =3D=3D NULL) { + if ((String =3D=3D NULL) || (MaxSize =3D=3D 0)) { return 0; } =20 @@ -1097,9 +1097,9 @@ AsciiStrnLenS ( UINTN Length; =20 // - // 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 f= unction returns zero. // - if (String =3D=3D NULL) { + if ((String =3D=3D NULL) || (MaxSize =3D=3D 0)) { return 0; } =20 --=20 1.9.5.msysgit.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel