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 2/2] ArmPlatformPkg/BootMonFs: eliminate deprecated string functions
Date: Fri, 28 Oct 2016 16:33:55 +0200	[thread overview]
Message-ID: <ac32783e-a462-379f-1ef5-0017ae64c4b8@redhat.com> (raw)
In-Reply-To: <1477651721-16958-3-git-send-email-ard.biesheuvel@linaro.org>

On 10/28/16 12:48, Ard Biesheuvel wrote:
> Get rid of functions that are no longer available when defining
> DISABLE_NEW_DEPRECATED_INTERFACES
> 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> ---
>  ArmPlatformPkg/FileSystem/BootMonFs/BootMonFsDir.c        |  8 +++-----
>  ArmPlatformPkg/FileSystem/BootMonFs/BootMonFsEntryPoint.c |  3 ++-
>  ArmPlatformPkg/FileSystem/BootMonFs/BootMonFsOpenClose.c  | 19 +++++++++++--------
>  3 files changed, 16 insertions(+), 14 deletions(-)
> 
> diff --git a/ArmPlatformPkg/FileSystem/BootMonFs/BootMonFsDir.c b/ArmPlatformPkg/FileSystem/BootMonFs/BootMonFsDir.c
> index 450a707f183c..64ea0ec68048 100644
> --- a/ArmPlatformPkg/FileSystem/BootMonFs/BootMonFsDir.c
> +++ b/ArmPlatformPkg/FileSystem/BootMonFs/BootMonFsDir.c
> @@ -304,7 +304,6 @@ SetFileName (
>    IN  CONST CHAR16         *FileName
>    )
>  {
> -  CHAR16           TruncFileName[MAX_NAME_LENGTH];
>    CHAR8            AsciiFileName[MAX_NAME_LENGTH];
>    BOOTMON_FS_FILE  *SameFile;
>  
> @@ -314,9 +313,7 @@ SetFileName (
>      FileName++;
>    }
>  
> -  StrnCpy (TruncFileName, FileName, MAX_NAME_LENGTH - 1);
> -  TruncFileName[MAX_NAME_LENGTH - 1] = 0;
> -  UnicodeStrToAsciiStr (TruncFileName, AsciiFileName);
> +  UnicodeStrToAsciiStrS (FileName, AsciiFileName, MAX_NAME_LENGTH);
>  
>    if (BootMonGetFileFromAsciiFileName (
>          File->Instance,
> @@ -327,7 +324,8 @@ SetFileName (
>      return EFI_ACCESS_DENIED;
>    } else {
>      // OK, change the filename.
> -    AsciiStrToUnicodeStr (AsciiFileName, File->Info->FileName);
> +    AsciiStrToUnicodeStrS (AsciiFileName, File->Info->FileName,
> +      (File->Info->Size - SIZE_OF_EFI_FILE_INFO) / sizeof (CHAR16));
>      return EFI_SUCCESS;
>    }
>  }
> diff --git a/ArmPlatformPkg/FileSystem/BootMonFs/BootMonFsEntryPoint.c b/ArmPlatformPkg/FileSystem/BootMonFs/BootMonFsEntryPoint.c
> index 3d71760fef99..a1150856f6ba 100644
> --- a/ArmPlatformPkg/FileSystem/BootMonFs/BootMonFsEntryPoint.c
> +++ b/ArmPlatformPkg/FileSystem/BootMonFs/BootMonFsEntryPoint.c
> @@ -98,7 +98,8 @@ BootMonGetFileFromAsciiFileName (
>    {
>      FileEntry = BOOTMON_FS_FILE_FROM_LINK_THIS (Entry);
>      if (FileEntry->Info != NULL) {
> -      UnicodeStrToAsciiStr (FileEntry->Info->FileName, OpenFileAsciiFileName);
> +      UnicodeStrToAsciiStrS (FileEntry->Info->FileName, OpenFileAsciiFileName,
> +        MAX_NAME_LENGTH);
>        AsciiFileNameToCompare = OpenFileAsciiFileName;
>      } else {
>        AsciiFileNameToCompare = FileEntry->HwDescription.Footer.Filename;
> diff --git a/ArmPlatformPkg/FileSystem/BootMonFs/BootMonFsOpenClose.c b/ArmPlatformPkg/FileSystem/BootMonFs/BootMonFsOpenClose.c
> index af2fe514f044..ae10055255ff 100644
> --- a/ArmPlatformPkg/FileSystem/BootMonFs/BootMonFsOpenClose.c
> +++ b/ArmPlatformPkg/FileSystem/BootMonFs/BootMonFsOpenClose.c
> @@ -101,7 +101,8 @@ WriteFileDescription (
>    Description->Attributes = 1;
>    Description->BlockStart = FileStart / BlockSize;
>    Description->BlockEnd   = Description->BlockStart + (FileSize / BlockSize);
> -  AsciiStrCpy (Description->Footer.Filename, FileName);
> +  AsciiStrCpyS (Description->Footer.Filename,
> +    sizeof Description->Footer.Filename, FileName);
>  
>  #ifdef MDE_CPU_ARM
>    Description->Footer.Offset  = HW_IMAGE_FOOTER_OFFSET;
> @@ -294,7 +295,7 @@ BootMonFsFlushFile (
>    DiskIo    = Instance->DiskIo;
>    BlockSize = Media->BlockSize;
>  
> -  UnicodeStrToAsciiStr (Info->FileName, AsciiFileName);
> +  UnicodeStrToAsciiStrS (Info->FileName, AsciiFileName, MAX_NAME_LENGTH);
>  
>    // If the file doesn't exist then find a space for it
>    if (File->HwDescription.RegionCount == 0) {
> @@ -513,6 +514,7 @@ BootMonFsOpenFile (
>    CHAR16               *Separator;
>    CHAR8                *AsciiFileName;
>    EFI_FILE_INFO        *Info;
> +  UINTN                AsciiFileNameSize;
>  
>    if (This == NULL) {
>      return EFI_INVALID_PARAMETER;
> @@ -621,15 +623,16 @@ BootMonFsOpenFile (
>    //
>    // BootMonFs interface requires ASCII filenames
>    //
> -  AsciiFileName = AllocatePool (StrLen (Path) + 1);
> +  AsciiFileNameSize = StrLen (Path) + 1;
> +  if (AsciiFileNameSize > MAX_NAME_LENGTH) {
> +    AsciiFileNameSize = MAX_NAME_LENGTH;
> +  }
> +  AsciiFileName = AllocatePool (AsciiFileNameSize);
>    if (AsciiFileName == NULL) {
>      Status = EFI_OUT_OF_RESOURCES;
>      goto Error;
>    }
> -  UnicodeStrToAsciiStr (Path, AsciiFileName);
> -  if (AsciiStrSize (AsciiFileName) > MAX_NAME_LENGTH) {
> -   AsciiFileName[MAX_NAME_LENGTH - 1] = '\0';
> -  }
> +  UnicodeStrToAsciiStrS (Path, AsciiFileName, AsciiFileNameSize);
>  
>    if ((AsciiFileName[0] == '\0') ||
>        (AsciiFileName[0] == '.' )    ) {
> @@ -688,7 +691,7 @@ BootMonFsOpenFile (
>  
>      Info->FileSize     = BootMonFsGetImageLength (File);
>      Info->PhysicalSize = BootMonFsGetPhysicalSize (File);
> -    AsciiStrToUnicodeStr (AsciiFileName, Info->FileName);
> +    AsciiStrToUnicodeStrS (AsciiFileName, Info->FileName, MAX_NAME_LENGTH);
>  
>      File->Info = Info;
>      Info = NULL;
> 

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


  reply	other threads:[~2016-10-28 14:33 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-28 10:48 [PATCH v2 0/2] ArmPlatformPkg: remove deprecated string function calls Ard Biesheuvel
2016-10-28 10:48 ` [PATCH v2 1/2] ArmPlatformPkg/ArmVExpressFastBootDxe: eliminate deprecated string functions Ard Biesheuvel
2016-10-28 14:23   ` Laszlo Ersek
2016-10-28 14:48   ` Leif Lindholm
2016-10-28 15:02     ` Ard Biesheuvel
2016-10-28 15:08       ` Laszlo Ersek
2016-10-28 15:13       ` Leif Lindholm
2016-10-28 15:14         ` Ard Biesheuvel
2016-10-28 15:26           ` Leif Lindholm
2016-10-28 10:48 ` [PATCH v2 2/2] ArmPlatformPkg/BootMonFs: " Ard Biesheuvel
2016-10-28 14:33   ` Laszlo Ersek [this message]
2016-10-28 14:52   ` Leif Lindholm

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=ac32783e-a462-379f-1ef5-0017ae64c4b8@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