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 D218882129 for ; Tue, 14 Feb 2017 21:58:57 -0800 (PST) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Feb 2017 21:58:57 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.35,164,1484035200"; d="scan'208";a="58708917" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by orsmga004.jf.intel.com with ESMTP; 14 Feb 2017 21:58:57 -0800 Received: from fmsmsx111.amr.corp.intel.com (10.18.116.5) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.248.2; Tue, 14 Feb 2017 21:58:56 -0800 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by fmsmsx111.amr.corp.intel.com (10.18.116.5) with Microsoft SMTP Server (TLS) id 14.3.248.2; Tue, 14 Feb 2017 21:58:56 -0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.88]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.204]) with mapi id 14.03.0248.002; Wed, 15 Feb 2017 13:58:53 +0800 From: "Yao, Jiewen" To: "Wu, Hao A" , "edk2-devel@lists.01.org" CC: "Gao, Liming" , "Kinney, Michael D" Thread-Topic: [PATCH] MdePkg/BaseLib: Refine logic for (Ascii)StrnLenS to handle MaxSize = 0 Thread-Index: AQHShmwNdcvf+Zxaake1vbhw2YaJqqFplETA Date: Wed, 15 Feb 2017 05:58:52 +0000 Message-ID: <74D8A39837DF1E4DA445A8C0B3885C503A8EE8AB@shsmsx102.ccr.corp.intel.com> References: <1487040161-5056-1-git-send-email-hao.a.wu@intel.com> In-Reply-To: <1487040161-5056-1-git-send-email-hao.a.wu@intel.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [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: , X-List-Received-Date: Wed, 15 Feb 2017 05:58:58 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: jiewen.yao@intel.com > -----Original Message----- > From: Wu, Hao A > Sent: Monday, February 13, 2017 6:43 PM > To: edk2-devel@lists.01.org > Cc: Wu, Hao A ; Yao, Jiewen ; > Gao, Liming ; Kinney, Michael D > > Subject: [PATCH] MdePkg/BaseLib: Refine logic for (Ascii)StrnLenS to hand= le > MaxSize =3D 0 >=20 > https://bugzilla.tianocore.org/show_bug.cgi?id=3D378 >=20 > 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(-) >=20 > 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) =3D=3D 0); >=20 > // > - // If String is a null pointer, then the StrnLenS function returns zer= o. > + // If String is a null pointer or MaxSize is 0, then the StrnLenS func= tion 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 return= s zero. > + // If String is a null pointer or MaxSize is 0, then the AsciiStrnLenS= function > returns zero. > // > - if (String =3D=3D NULL) { > + if ((String =3D=3D NULL) || (MaxSize =3D=3D 0)) { > return 0; > } >=20 > -- > 1.9.5.msysgit.0