From: "Wu, Hao A" <hao.a.wu@intel.com>
To: "Kinney, Michael D" <michael.d.kinney@intel.com>,
"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Cc: "Yao, Jiewen" <jiewen.yao@intel.com>,
"Gao, Liming" <liming.gao@intel.com>
Subject: Re: [PATCH 1/6] MdePkg/BaseLib: Refine (Ascii)StrnLenS functions logic
Date: Fri, 16 Dec 2016 03:21:36 +0000 [thread overview]
Message-ID: <B80AF82E9BFB8E4FBD8C89DA810C6A0931C586A2@SHSMSX104.ccr.corp.intel.com> (raw)
In-Reply-To: <E92EE9817A31E24EB0585FDF735412F56487B843@ORSMSX113.amr.corp.intel.com>
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
>
> Reviewed-by: Michael Kinney <michael.d.kinney@intel.com>
>
> > -----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 <hao.a.wu@intel.com>; Kinney, Michael D
> <michael.d.kinney@intel.com>;
> > Yao, Jiewen <jiewen.yao@intel.com>; Gao, Liming <liming.gao@intel.com>
> > Subject: [edk2] [PATCH 1/6] MdePkg/BaseLib: Refine (Ascii)StrnLenS functions
> logic
> >
> > This commit refines the logic for AsciiStrnLenS and StrnLenS. It makes the
> > logic more straightforward to prevent possible mis-reports by static code
> > checkers.
> >
> > Cc: Jiewen Yao <jiewen.yao@intel.com>
> > Cc: Liming Gao <liming.gao@intel.com>
> > Cc: Michael D Kinney <michael.d.kinney@intel.com>
> > Contributed-under: TianoCore Contribution Agreement 1.0
> > Signed-off-by: Hao Wu <hao.a.wu@intel.com>
> > ---
> > 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 = 0; (Length < MaxSize) && (*String != 0); String++, Length++) {
> > - ;
> > + Length = 0;
> > + while (String[Length] != 0) {
> > + if (Length >= MaxSize) {
> > + break;
> > + }
> > + Length++;
> > }
> > return Length;
> > }
> > @@ -571,8 +575,12 @@ AsciiStrnLenS (
> > // String then AsciiStrnLenS returns MaxSize. At most the first MaxSize
> characters
> > of String shall
> > // be accessed by AsciiStrnLenS.
> > //
> > - for (Length = 0; (Length < MaxSize) && (*String != 0); String++, Length++) {
> > - ;
> > + Length = 0;
> > + while (String[Length] != 0) {
> > + if (Length >= 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
next prev parent reply other threads:[~2016-12-16 3:21 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-14 11:26 [PATCH 0/6] Refine code logics to prevent possible mis-reports by static code checkers Hao Wu
2016-12-14 11:26 ` [PATCH 1/6] MdePkg/BaseLib: Refine (Ascii)StrnLenS functions logic Hao Wu
2016-12-15 23:54 ` Kinney, Michael D
2016-12-16 3:21 ` Wu, Hao A [this message]
2016-12-14 11:26 ` [PATCH 2/6] MdePkg/BaseLib: Add an additional check within (Ascii)StrnCmp Hao Wu
2016-12-15 23:54 ` Kinney, Michael D
2016-12-14 11:26 ` [PATCH 3/6] MdePkg/MemoryLib: Refine InternalMemSetMem16|32|64 functions logic Hao Wu
2016-12-15 23:55 ` Kinney, Michael D
2016-12-14 11:26 ` [PATCH 4/6] MdeModulePkg/DxeNetLib: Rewrite NetblockChecksum function logic Hao Wu
2016-12-15 2:45 ` Fu, Siyuan
2016-12-15 7:41 ` Ye, Ting
2016-12-15 7:51 ` Wu, Jiaxin
2016-12-14 11:26 ` [PATCH 5/6] MdeModulePkg/UefiPxeBcDxe: Refine the CvtNum " Hao Wu
2016-12-15 2:47 ` Fu, Siyuan
2016-12-15 7:33 ` Ye, Ting
2016-12-15 7:51 ` Wu, Jiaxin
2016-12-14 11:26 ` [PATCH 6/6] NetworkPkg: Refine UintnToAscDecWithFormat functions logic Hao Wu
2016-12-15 2:47 ` Fu, Siyuan
2016-12-15 7:32 ` Ye, Ting
2016-12-15 7:52 ` Wu, Jiaxin
2016-12-18 3:04 ` [PATCH 0/6] Refine code logics to prevent possible mis-reports by static code checkers Heyi Guo
2016-12-20 8:14 ` Wu, Hao A
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=B80AF82E9BFB8E4FBD8C89DA810C6A0931C586A2@SHSMSX104.ccr.corp.intel.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox