From: "Mike Maslenkin" <mike.maslenkin@gmail.com>
To: "Chang, Abner" <Abner.Chang@amd.com>
Cc: "devel@edk2.groups.io" <devel@edk2.groups.io>,
"nicklew@nvidia.com" <nicklew@nvidia.com>,
"igork@ami.com" <igork@ami.com>
Subject: Re: [edk2-devel] [PATCH 9/9] RedfishClientPkg: fix StrnCpyS arguments
Date: Fri, 27 Oct 2023 02:51:09 +0300 [thread overview]
Message-ID: <CAL77WPD-xNDWaonQzV1BHLMJVb4k-AjBu9hwZLW1nj+D-R+0gA@mail.gmail.com> (raw)
In-Reply-To: <MN2PR12MB3966417F58EBC692B5DC9D89EAC5A@MN2PR12MB3966.namprd12.prod.outlook.com>
On Mon, Oct 2, 2023 at 5:56 AM Chang, Abner <Abner.Chang@amd.com> wrote:
>
> [AMD Official Use Only - General]
>
> > -----Original Message-----
> > From: Mike Maslenkin <mike.maslenkin@gmail.com>
> > Sent: Saturday, September 30, 2023 5:59 AM
> > To: devel@edk2.groups.io
> > Cc: Chang, Abner <Abner.Chang@amd.com>; nicklew@nvidia.com;
> > igork@ami.com; Mike Maslenkin <mike.maslenkin@gmail.com>
> > Subject: [PATCH 9/9] RedfishClientPkg: fix StrnCpyS arguments
> >
> > Caution: This message originated from an External Source. Use proper caution
> > when opening attachments, clicking links, or responding.
> >
> >
> > StrnCpyS accepts string length in characters, not in bytes.
> >
> > Signed-off-by: Mike Maslenkin <mike.maslenkin@gmail.com>
> > ---
> > RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.c
> > b/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.c
> > index 8ac165dec59e..c19d4a46d6af 100644
> > --- a/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.c
> > +++ b/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.c
> > @@ -331,7 +331,7 @@ NewInternalInstance (
> > }
> >
> >
> >
> > NewInternalData->NodeName = AllocateZeroPool (StrSize (NodeName));
> >
> > - StrnCpyS (NewInternalData->NodeName, StrSize (NodeName), (CONST
> > CHAR16 *)NodeName, StrLen (NodeName));
> >
> > + StrnCpyS (NewInternalData->NodeName, StrLen (NodeName) + 1, (CONST
> > CHAR16 *)NodeName, StrLen (NodeName));
> The original code is already the size of string that includes NULL terminator. However, we should check if NewInternalData->NodeName is NULL or not before copying the string. Mike, could you please help to add this check?
>
> Thanks
> Abner
>
Hi, Abner
The problem is not with NULL terminator
The problem is that StrnCpyS takes a number of unicode chars as a
second parameter, not a string size in bytes returned by StrSize().
So I left this patch unmodified and added two additional patches
required for NULL pointer check.
Thanks,
Mike.
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#110144): https://edk2.groups.io/g/devel/message/110144
Mute This Topic: https://groups.io/mt/101667469/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
next prev parent reply other threads:[~2023-10-26 23:51 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-29 21:59 [edk2-devel] [PATCH 0/9] RedfishClientPkg: various minor fixes Mike Maslenkin
2023-09-29 21:59 ` [edk2-devel] [PATCH 1/9] RedfishClientPkg: fix format used for output __func__ Mike Maslenkin
2023-10-02 2:16 ` Chang, Abner via groups.io
2023-09-29 21:59 ` [edk2-devel] [PATCH 2/9] RedfishClientPkg: fix DEBUG macro arguments Mike Maslenkin
2023-10-02 2:16 ` Chang, Abner via groups.io
2023-09-29 21:59 ` [edk2-devel] [PATCH 3/9] RedfishLib: remove redudant zeroing Mike Maslenkin
2023-10-02 2:18 ` Chang, Abner via groups.io
2023-09-29 21:59 ` [edk2-devel] [PATCH 4/9] RedfishClientPkg: RedfishFeatureUtilityLib: fix memory leaks Mike Maslenkin
2023-10-02 2:25 ` Chang, Abner via groups.io
2023-09-29 21:59 ` [edk2-devel] [PATCH 5/9] RedfishClientPkg: reduce identation level by adding early return Mike Maslenkin
2023-10-02 3:00 ` Chang, Abner via groups.io
2023-10-02 3:09 ` Chang, Abner via groups.io
2023-10-11 1:53 ` Nickle Wang via groups.io
2023-09-29 21:59 ` [edk2-devel] [PATCH 6/9] RedfishClientPkg: fix memory leaks while applying feature settings Mike Maslenkin
2023-10-02 2:30 ` Chang, Abner via groups.io
2023-09-29 21:59 ` [edk2-devel] [PATCH 7/9] RedfishClientPkg: fix memory leak Mike Maslenkin
2023-10-02 2:36 ` Chang, Abner via groups.io
2023-09-29 21:59 ` [edk2-devel] [PATCH 8/9] RedfishClientPkg: fix pragma pack usage Mike Maslenkin
2023-10-02 2:45 ` Chang, Abner via groups.io
2023-10-02 12:14 ` Mike Maslenkin
2023-10-11 1:49 ` Nickle Wang via groups.io
2023-10-03 2:02 ` Chang, Abner via groups.io
2023-09-29 21:59 ` [edk2-devel] [PATCH 9/9] RedfishClientPkg: fix StrnCpyS arguments Mike Maslenkin
2023-10-02 2:56 ` Chang, Abner via groups.io
2023-10-26 23:51 ` Mike Maslenkin [this message]
2023-10-27 2:33 ` Chang, Abner via groups.io
2023-10-26 8:33 ` [edk2-devel] [PATCH 0/9] RedfishClientPkg: various minor fixes Nickle Wang via groups.io
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=CAL77WPD-xNDWaonQzV1BHLMJVb4k-AjBu9hwZLW1nj+D-R+0gA@mail.gmail.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