From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id AA8D51A1E43 for ; Wed, 26 Oct 2016 05:05:00 -0700 (PDT) Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 50A06FA8B5; Wed, 26 Oct 2016 12:05:00 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-27.phx2.redhat.com [10.3.116.27]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u9QC4wrQ015714; Wed, 26 Oct 2016 08:04:59 -0400 To: Ard Biesheuvel , edk2-devel@ml01.01.org, leif.lindholm@linaro.org References: <1477469862-10046-1-git-send-email-ard.biesheuvel@linaro.org> <1477469862-10046-6-git-send-email-ard.biesheuvel@linaro.org> Cc: ryan.harkin@linaro.org From: Laszlo Ersek Message-ID: <18065f00-14d0-dd72-04a9-57e02366bd42@redhat.com> Date: Wed, 26 Oct 2016 14:04:58 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <1477469862-10046-6-git-send-email-ard.biesheuvel@linaro.org> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 26 Oct 2016 12:05:00 +0000 (UTC) Subject: Re: [PATCH v2 5/6] ArmPkg/BdsLib: eliminate calls to 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: Wed, 26 Oct 2016 12:05:00 -0000 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit 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 > --- > 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 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, >