public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Laszlo Ersek <lersek@redhat.com>
To: Leif Lindholm <leif.lindholm@linaro.org>,
	Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: edk2-devel@ml01.01.org, ryan.harkin@linaro.org
Subject: Re: [PATCH v2 5/9] EmbeddedPkg/AndroidFastboot: eliminate deprecated string function calls
Date: Fri, 28 Oct 2016 15:41:32 +0200	[thread overview]
Message-ID: <6d788dd2-34d5-7a8e-bbe8-4ce51651f586@redhat.com> (raw)
In-Reply-To: <20161028133625.GM1161@bivouac.eciton.net>

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 <ard.biesheuvel@linaro.org>
>> ---
>>  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


  parent reply	other threads:[~2016-10-28 13:41 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-28 10:44 [PATCH v2 0/9] EmbeddedPkg: eliminate calls to deprecated functions Ard Biesheuvel
2016-10-28 10:44 ` [PATCH v2 1/9] EmbeddedPkg/AndroidFastbootTransportTcpDxe: remove broken hostname handling Ard Biesheuvel
2016-10-28 12:40   ` Leif Lindholm
2016-10-28 10:44 ` [PATCH v2 2/9] EmbeddedPkg: remove unused PrePiHobListPointerLib Ard Biesheuvel
2016-10-28 12:40   ` Leif Lindholm
2016-10-28 10:44 ` [PATCH v2 3/9] EmbeddedPkg: add missing modules Ard Biesheuvel
2016-10-28 12:41   ` Leif Lindholm
2016-10-28 10:44 ` [PATCH v2 4/9] EmbeddedPkg/GdbDebugAgent: fix VOID* cast of incorrect size Ard Biesheuvel
2016-10-28 12:47   ` Leif Lindholm
2016-10-28 10:44 ` [PATCH v2 5/9] EmbeddedPkg/AndroidFastboot: eliminate deprecated string function calls Ard Biesheuvel
2016-10-28 13:18   ` Laszlo Ersek
2016-10-28 13:36   ` Leif Lindholm
2016-10-28 13:40     ` Ard Biesheuvel
2016-10-28 13:52       ` Leif Lindholm
2016-10-28 14:04         ` Ard Biesheuvel
2016-10-28 14:05         ` Laszlo Ersek
2016-10-28 13:41     ` Laszlo Ersek [this message]
2016-10-28 10:44 ` [PATCH v2 6/9] EmbeddedPkg/Ebl: " Ard Biesheuvel
2016-10-28 13:31   ` Laszlo Ersek
2016-10-28 14:31   ` Leif Lindholm
2016-10-28 10:44 ` [PATCH v2 7/9] EmbeddedPkg/EfiFileLib: " Ard Biesheuvel
2016-10-28 14:37   ` Leif Lindholm
2016-10-28 10:44 ` [PATCH v2 8/9] EmbeddedPkg/MmcDxe: " Ard Biesheuvel
2016-10-28 13:40   ` Laszlo Ersek
2016-10-28 14:39   ` Leif Lindholm
2016-10-28 10:44 ` [PATCH v2 9/9] EmbeddedPkg: enable -DDISABLE_NEW_DEPRECATED_INTERFACES Ard Biesheuvel
2016-10-28 14:40   ` Leif Lindholm
2016-10-28 15:16 ` [PATCH v2 0/9] EmbeddedPkg: eliminate calls to deprecated functions Ard Biesheuvel

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=6d788dd2-34d5-7a8e-bbe8-4ce51651f586@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