From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) (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 31E4B82011 for ; Thu, 15 Dec 2016 19:21:45 -0800 (PST) Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga103.fm.intel.com with ESMTP; 15 Dec 2016 19:21:39 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,355,1477983600"; d="scan'208";a="42937264" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by orsmga005.jf.intel.com with ESMTP; 15 Dec 2016 19:21:39 -0800 Received: from fmsmsx102.amr.corp.intel.com (10.18.124.200) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.248.2; Thu, 15 Dec 2016 19:21:38 -0800 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by FMSMSX102.amr.corp.intel.com (10.18.124.200) with Microsoft SMTP Server (TLS) id 14.3.248.2; Thu, 15 Dec 2016 19:21:38 -0800 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.9]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.97]) with mapi id 14.03.0248.002; Fri, 16 Dec 2016 11:21:36 +0800 From: "Wu, Hao A" To: "Kinney, Michael D" , "edk2-devel@lists.01.org" CC: "Yao, Jiewen" , "Gao, Liming" Thread-Topic: [edk2] [PATCH 1/6] MdePkg/BaseLib: Refine (Ascii)StrnLenS functions logic Thread-Index: AQHSVf0AfOdGEuXL8kO4ErQJNKXMbqEJKxwAgAC+OpA= Date: Fri, 16 Dec 2016 03:21:36 +0000 Message-ID: References: <1481714811-12568-1-git-send-email-hao.a.wu@intel.com> <1481714811-12568-2-git-send-email-hao.a.wu@intel.com> In-Reply-To: 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 1/6] MdePkg/BaseLib: Refine (Ascii)StrnLenS functions logic 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:21:45 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Mike, I have noticed that the patch has the following issue: According to the comments in functions [Ascii]StrnLens, at most the first MaxSize characters of String shall be accessed by those two APIs. But my patch will access (MaxSize + 1) characters of String if there is no no null character in the first MaxSize characters in String. Sorry for the issue, I will send out a V2 of the series with this patch updated. Best Regards, Hao Wu > -----Original Message----- > From: Kinney, Michael D > Sent: Friday, December 16, 2016 7:55 AM > To: Wu, Hao A; edk2-devel@lists.01.org; Kinney, Michael D > Cc: Wu, Hao A; Yao, Jiewen; Gao, Liming > Subject: RE: [edk2] [PATCH 1/6] MdePkg/BaseLib: Refine (Ascii)StrnLenS > functions logic >=20 > Reviewed-by: Michael Kinney >=20 > > -----Original Message----- > > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of = Hao > Wu > > Sent: Wednesday, December 14, 2016 3:27 AM > > To: edk2-devel@lists.01.org > > Cc: Wu, Hao A ; Kinney, Michael D > ; > > Yao, Jiewen ; Gao, Liming > > Subject: [edk2] [PATCH 1/6] MdePkg/BaseLib: Refine (Ascii)StrnLenS func= tions > logic > > > > This commit refines the logic for AsciiStrnLenS and StrnLenS. It makes = the > > logic more straightforward to prevent possible mis-reports by static co= de > > checkers. > > > > Cc: Jiewen Yao > > Cc: Liming Gao > > Cc: Michael D Kinney > > Contributed-under: TianoCore Contribution Agreement 1.0 > > Signed-off-by: Hao Wu > > --- > > MdePkg/Library/BaseLib/SafeString.c | 16 ++++++++++++---- > > 1 file changed, 12 insertions(+), 4 deletions(-) > > > > diff --git a/MdePkg/Library/BaseLib/SafeString.c > > b/MdePkg/Library/BaseLib/SafeString.c > > index ede2f4c..3247d28 100644 > > --- a/MdePkg/Library/BaseLib/SafeString.c > > +++ b/MdePkg/Library/BaseLib/SafeString.c > > @@ -143,8 +143,12 @@ StrnLenS ( > > // String then StrnLenS returns MaxSize. At most the first MaxSize > characters of > > String shall > > // be accessed by StrnLenS. > > // > > - for (Length =3D 0; (Length < MaxSize) && (*String !=3D 0); String++,= Length++) { > > - ; > > + Length =3D 0; > > + while (String[Length] !=3D 0) { > > + if (Length >=3D MaxSize) { > > + break; > > + } > > + Length++; > > } > > return Length; > > } > > @@ -571,8 +575,12 @@ AsciiStrnLenS ( > > // String then AsciiStrnLenS returns MaxSize. At most the first MaxS= ize > characters > > of String shall > > // be accessed by AsciiStrnLenS. > > // > > - for (Length =3D 0; (Length < MaxSize) && (*String !=3D 0); String++,= Length++) { > > - ; > > + Length =3D 0; > > + while (String[Length] !=3D 0) { > > + if (Length >=3D MaxSize) { > > + break; > > + } > > + Length++; > > } > > return Length; > > } > > -- > > 1.9.5.msysgit.0 > > > > _______________________________________________ > > edk2-devel mailing list > > edk2-devel@lists.01.org > > https://lists.01.org/mailman/listinfo/edk2-devel