From: "Rebecca Cran" <rebecca@nuviainc.com>
To: Michael D Kinney <michael.d.kinney@intel.com>, devel@edk2.groups.io
Cc: Jayaprakash Nevara <n.jayaprakash@intel.com>
Subject: Re: [edk2-libc Patch] StdLib/LibC: Fix corner case in use of StrnCpyS() and AsciiStrnCpyS()
Date: Wed, 1 Sep 2021 07:24:13 -0600 [thread overview]
Message-ID: <3c89308c-dab5-3a48-267e-7b88e2c31875@nuviainc.com> (raw)
In-Reply-To: <20210901071858.1686-1-michael.d.kinney@intel.com>
Reviewed-by: Rebecca Cran <rebecca@nuviainc.com>
--
Rebecca Cran
On 9/1/21 1:18 AM, Michael D Kinney wrote:
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3361
>
> DestMax must be > Length or StrnCpyS() and AsciiStrnCpyS()
> return an error. Set DestMax to n + 1 for these LibC APIs.
>
> Cc: Rebecca Cran <rebecca@nuviainc.com>
> Cc: Jayaprakash Nevara <n.jayaprakash@intel.com>
> Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
> ---
> StdLib/LibC/String/Copying.c | 2 +-
> StdLib/LibC/Wchar/Copying.c | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/StdLib/LibC/String/Copying.c b/StdLib/LibC/String/Copying.c
> index c296714..a50331b 100644
> --- a/StdLib/LibC/String/Copying.c
> +++ b/StdLib/LibC/String/Copying.c
> @@ -90,7 +90,7 @@ strcpy(char * __restrict s1, const char * __restrict s2)
> **/
> char *strncpy(char * __restrict s1, const char * __restrict s2, size_t n)
> {
> - AsciiStrnCpyS (s1, n, s2, n);
> + AsciiStrnCpyS (s1, n + 1, s2, n);
> return s1;
> //char *dest = s1;
>
> diff --git a/StdLib/LibC/Wchar/Copying.c b/StdLib/LibC/Wchar/Copying.c
> index 45ceda7..d5a1149 100644
> --- a/StdLib/LibC/Wchar/Copying.c
> +++ b/StdLib/LibC/Wchar/Copying.c
> @@ -44,7 +44,7 @@ wchar_t *wcscpy(wchar_t * __restrict s1, const wchar_t * __restrict s2)
> **/
> wchar_t *wcsncpy(wchar_t * __restrict s1, const wchar_t * __restrict s2, size_t n)
> {
> - return (wchar_t *)StrnCpyS ((CHAR16 *)s1, (UINTN)n, (CONST CHAR16 *)s2, (UINTN)n);
> + return (wchar_t *)StrnCpyS ((CHAR16 *)s1, (UINTN)n + 1, (CONST CHAR16 *)s2, (UINTN)n);
> }
>
> /** The wmemcpy function copies n wide characters from the object pointed to by
prev parent reply other threads:[~2021-09-01 13:24 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-01 7:18 [edk2-libc Patch] StdLib/LibC: Fix corner case in use of StrnCpyS() and AsciiStrnCpyS() Michael D Kinney
2021-09-01 13:24 ` Rebecca Cran [this message]
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=3c89308c-dab5-3a48-267e-7b88e2c31875@nuviainc.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