public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Laszlo Ersek <lersek@redhat.com>
To: Ard Biesheuvel <ard.biesheuvel@linaro.org>,
	edk2-devel@ml01.01.org, leif.lindholm@linaro.org
Cc: ryan.harkin@linaro.org
Subject: Re: [PATCH v2 5/6] ArmPkg/BdsLib: eliminate calls to deprecated string functions
Date: Wed, 26 Oct 2016 14:04:58 +0200	[thread overview]
Message-ID: <18065f00-14d0-dd72-04a9-57e02366bd42@redhat.com> (raw)
In-Reply-To: <1477469862-10046-6-git-send-email-ard.biesheuvel@linaro.org>

On 10/26/16 10:17, Ard Biesheuvel wrote:
> Remove calls to deprecated string functions like AsciiStrCpy() and
> UnicodeStrToAsciiStr()
> 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> ---
>  ArmPkg/Library/BdsLib/BdsFilePath.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/ArmPkg/Library/BdsLib/BdsFilePath.c b/ArmPkg/Library/BdsLib/BdsFilePath.c
> index aefeaed4ffb5..f9d8c4c205bf 100644
> --- a/ArmPkg/Library/BdsLib/BdsFilePath.c
> +++ b/ArmPkg/Library/BdsLib/BdsFilePath.c
> @@ -964,7 +964,7 @@ Mtftp4CheckPacket (
>        Step      = (Context->DownloadedNbOfBytes   * TFTP_PROGRESS_SLIDER_STEPS) / Context->FileSize;
>        if (Step > LastStep) {
>          Print (mTftpProgressDelete);
> -        StrCpy (Progress, mTftpProgressFrame);
> +        CopyMem (Progress, mTftpProgressFrame, sizeof mTftpProgressFrame);
>          for (Index = 1; Index < Step; Index++) {
>            Progress[Index] = L'=';
>          }

This is fine now; the relevant definitions are

STATIC CONST CHAR16 mTftpProgressFrame[] = ...

#define TFTP_PROGRESS_MESSAGE_SIZE  ((sizeof (mTftpProgressFrame) /
sizeof (CHAR16)) + 12)

  CHAR16            Progress[TFTP_PROGRESS_MESSAGE_SIZE];

Because TFTP_PROGRESS_MESSAGE_SIZE always results in a larger count of
UCS2 characters, it is safe to copy mTftpProgressFrame into Progress.
(IOW, the original code was safe.)

Reviewed-by: Laszlo Ersek <lersek@redhat.com>

Thanks
Laszlo

> @@ -1044,6 +1044,7 @@ BdsTftpLoadImage (
>    UINT64                   FileSize;
>    UINT64                   TftpBufferSize;
>    BDS_TFTP_CONTEXT         *TftpContext;
> +  UINTN                    PathNameLen;
>  
>    ASSERT(IS_DEVICE_PATH_NODE (RemainingDevicePath, MESSAGING_DEVICE_PATH, MSG_IPv4_DP));
>    IPv4DevicePathNode = (IPv4_DEVICE_PATH*)RemainingDevicePath;
> @@ -1187,8 +1188,9 @@ BdsTftpLoadImage (
>  
>    // The Device Path might contain multiple FilePath nodes
>    PathName      = ConvertDevicePathToText ((EFI_DEVICE_PATH_PROTOCOL*)(IPv4DevicePathNode + 1), FALSE, FALSE);
> -  AsciiFilePath = AllocatePool (StrLen (PathName) + 1);
> -  UnicodeStrToAsciiStr (PathName, AsciiFilePath);
> +  PathNameLen   = StrLen (PathName) + 1;
> +  AsciiFilePath = AllocatePool (PathNameLen);
> +  UnicodeStrToAsciiStrS (PathName, AsciiFilePath, PathNameLen);
>  
>    //
>    // Try to get the size of the file in bytes from the server. If it fails,
> 



  reply	other threads:[~2016-10-26 12:05 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-26  8:17 [PATCH v2 0/6] ArmPkg: eliminate calls to deprecated functions Ard Biesheuvel
2016-10-26  8:17 ` [PATCH v2 1/6] ArmPkg: add missing components Ard Biesheuvel
2016-10-26  8:17 ` [PATCH v2 2/6] ArmPkg/ArmCortexA9Lib RVCT: remove incompatible GCC include Ard Biesheuvel
2016-10-26  8:17 ` [PATCH v2 3/6] ArmPkg/LinuxLoader: eliminate calls to deprecated string functions Ard Biesheuvel
2016-10-26  8:17 ` [PATCH v2 4/6] ArmPkg/SemihostFs: " Ard Biesheuvel
2016-10-26 11:55   ` Laszlo Ersek
2016-10-26 12:24     ` Ryan Harkin
2016-10-26  8:17 ` [PATCH v2 5/6] ArmPkg/BdsLib: " Ard Biesheuvel
2016-10-26 12:04   ` Laszlo Ersek [this message]
2016-10-26  8:17 ` [PATCH v2 6/6] ArmPkg: enable -DDISABLE_NEW_DEPRECATED_INTERFACES Ard Biesheuvel
2016-10-26 12:11 ` [PATCH v2 0/6] ArmPkg: eliminate calls to deprecated functions Ryan Harkin
2016-10-26 12:13   ` Ard Biesheuvel
2016-10-26 12:21     ` Ryan Harkin
2016-10-26 13:06       ` Ryan Harkin

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=18065f00-14d0-dd72-04a9-57e02366bd42@redhat.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