From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-x231.google.com (mail-wm0-x231.google.com [IPv6:2a00:1450:400c:c09::231]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id ADBA181DAF for ; Fri, 28 Oct 2016 07:53:02 -0700 (PDT) Received: by mail-wm0-x231.google.com with SMTP id e69so106963258wmg.0 for ; Fri, 28 Oct 2016 07:53:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=R34EaOxjOZEQ/pDtLP6LYLU3RY0r7cv+zlsLVMMuuTk=; b=jZer1ALCTIFwwuOk6dXNy94wNexKrCUQvhMOcJ+N3hRPltDib49QDZia+CAt1VnIKq X9RfB2cdFqo6DJUCqmu2CcGbTrTuM40qcdQ1Ku77mz35mVK4NDJSNf7VvFxiGtWO2Wtx rmJUXFoELb5kqJSf3/zXSfu/dxE1YKB4KGIP8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=R34EaOxjOZEQ/pDtLP6LYLU3RY0r7cv+zlsLVMMuuTk=; b=lGrdxweS0ca5TUZBkde6crEKQbrrATXxnaLQw14BtlMIBCnOBYw7pvTblbOYOWQRg/ 5VGdwYD9kri8ygYSKcPuHVcwKxx/Xl+TA+zQ90xYEf2WEXhh+jJ8dJ/CXhsUOaCJWmFu E2wF7X9PXLC3MekORZwm7GTC3uUpPDPKffW6MPyX4CDVOhsqSqqVsT2ib8QVUNSmpczK vT3Sqpm4MF+I3Fh0QVajI5sLGYRWUDsAWOkENupX2GdBX8Lntg0mZMIqEMdL1gtTNZFK E6hI3/QumG7P0k9fC+2j2U7GfQ2So0PkHoKAlQ0+sht3OP2RGdJZWPt4+fU1eNca85Dh ebnQ== X-Gm-Message-State: ABUngveeNym+TCOUIV7IpIul/BuWTQwrL4oA2pN8+AMxMiQwVtQwni3HW03pTyl09grtafCu X-Received: by 10.28.174.209 with SMTP id x200mr3411210wme.55.1477666381755; Fri, 28 Oct 2016 07:53:01 -0700 (PDT) Received: from bivouac.eciton.net (bivouac.eciton.net. [2a00:1098:0:86:1000:23:0:2]) by smtp.gmail.com with ESMTPSA id k17sm9285056wmd.8.2016.10.28.07.53.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 28 Oct 2016 07:53:01 -0700 (PDT) Date: Fri, 28 Oct 2016 15:52:59 +0100 From: Leif Lindholm To: Ard Biesheuvel Cc: edk2-devel@lists.01.org, lersek@redhat.com, ryan.harkin@linaro.org Message-ID: <20161028145259.GV1161@bivouac.eciton.net> References: <1477651721-16958-1-git-send-email-ard.biesheuvel@linaro.org> <1477651721-16958-3-git-send-email-ard.biesheuvel@linaro.org> MIME-Version: 1.0 In-Reply-To: <1477651721-16958-3-git-send-email-ard.biesheuvel@linaro.org> User-Agent: Mutt/1.5.23 (2014-03-12) Subject: Re: [PATCH v2 2/2] ArmPlatformPkg/BootMonFs: eliminate deprecated string functions X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Oct 2016 14:53:03 -0000 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Fri, Oct 28, 2016 at 11:48:41AM +0100, 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 Reviewed-by: Leif Lindholm > --- > 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; > -- > 2.7.4 >