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 28C7A81D88 for ; Fri, 28 Oct 2016 06:41:34 -0700 (PDT) Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (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 33DB7C04D2A9; Fri, 28 Oct 2016 13:41:34 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-38.phx2.redhat.com [10.3.116.38]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u9SDfWps013276; Fri, 28 Oct 2016 09:41:33 -0400 To: Leif Lindholm , Ard Biesheuvel References: <1477651478-16830-1-git-send-email-ard.biesheuvel@linaro.org> <1477651478-16830-6-git-send-email-ard.biesheuvel@linaro.org> <20161028133625.GM1161@bivouac.eciton.net> Cc: edk2-devel@ml01.01.org, ryan.harkin@linaro.org From: Laszlo Ersek Message-ID: <6d788dd2-34d5-7a8e-bbe8-4ce51651f586@redhat.com> Date: Fri, 28 Oct 2016 15:41:32 +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: <20161028133625.GM1161@bivouac.eciton.net> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Fri, 28 Oct 2016 13:41:34 +0000 (UTC) Subject: Re: [PATCH v2 5/9] EmbeddedPkg/AndroidFastboot: eliminate deprecated string function calls 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 13:41:34 -0000 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit On 10/28/16 15:36, Leif Lindholm wrote: > On Fri, Oct 28, 2016 at 11:44:34AM +0100, Ard Biesheuvel wrote: >> Get rid of calls to unsafe string functions. These are deprecated and may >> be removed in the future. >> >> Contributed-under: TianoCore Contribution Agreement 1.0 >> Signed-off-by: Ard Biesheuvel >> --- >> EmbeddedPkg/Application/AndroidFastboot/AndroidBootImg.c | 3 ++- >> EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.c | 11 ++++++----- >> 2 files changed, 8 insertions(+), 6 deletions(-) >> >> diff --git a/EmbeddedPkg/Application/AndroidFastboot/AndroidBootImg.c b/EmbeddedPkg/Application/AndroidFastboot/AndroidBootImg.c >> index bbca90fc08a2..f3e770bcc980 100644 >> --- a/EmbeddedPkg/Application/AndroidFastboot/AndroidBootImg.c >> +++ b/EmbeddedPkg/Application/AndroidFastboot/AndroidBootImg.c >> @@ -84,7 +84,8 @@ ParseAndroidBootImg ( >> + ALIGN_VALUE (Header->KernelSize, Header->PageSize)); >> } >> >> - AsciiStrnCpy (KernelArgs, Header->KernelArgs, BOOTIMG_KERNEL_ARGS_SIZE); >> + AsciiStrnCpyS (KernelArgs, BOOTIMG_KERNEL_ARGS_SIZE, Header->KernelArgs, >> + BOOTIMG_KERNEL_ARGS_SIZE); >> >> return EFI_SUCCESS; >> } >> diff --git a/EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.c b/EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.c >> index 9ddc34f57cf4..c5e8a7e34af2 100644 >> --- a/EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.c >> +++ b/EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.c >> @@ -99,7 +99,7 @@ HandleDownload ( >> IN CHAR8 *NumBytesString >> ) >> { >> - CHAR8 Response[12] = "DATA"; >> + CHAR8 Response[13]; >> CHAR16 OutputString[FASTBOOT_STRING_MAX_LENGTH]; >> >> // Argument is 8-character ASCII string hex representation of number of bytes >> @@ -127,8 +127,10 @@ HandleDownload ( >> if (mDataBuffer == NULL) { >> SEND_LITERAL ("FAILNot enough memory"); >> } else { >> - AsciiStrnCpy (Response + 4, NumBytesString, 8); >> - mTransport->Send (sizeof(Response), Response, &mFatalSendErrorEvent); >> + ZeroMem (Response, sizeof Response); >> + AsciiSPrint (Response, sizeof Response, "DATA%x", >> + (UINT32)mNumDataBytes); > > I'll try to keep the bikeshedding to a minimum, but since > mNumDataBytes is generated from NumBytesString in the first place, why > not do > "DATA%s", NumBytesString > ? Because of "0000000000000000000000000000000000000000000000012". Thanks Laszlo