From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-x22d.google.com (mail-wm0-x22d.google.com [IPv6:2a00:1450:400c:c09::22d]) (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 06D4681D66 for ; Fri, 28 Oct 2016 06:36:33 -0700 (PDT) Received: by mail-wm0-x22d.google.com with SMTP id 140so76253558wmv.0 for ; Fri, 28 Oct 2016 06:36:33 -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=yMc8OZFkB7LKUqw6ZlBuN5gbIeUb5ZwKQoMgonp7v0Q=; b=XX+LOD9NaosYhhl4igtfitcz2Bo953GYVzEQscfzhxXZIQu8N4CeAqg/mvkGY7Tjci C614mwqAo3Na5/VTlDhPIt8V7fjNmZK1/tZ2eSRLUrPsm5luTdUhaJJNqZNNse93SduD EoBynsDPTDo/v62TNcF/BzjgJLkS5kImzB5vY= 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=yMc8OZFkB7LKUqw6ZlBuN5gbIeUb5ZwKQoMgonp7v0Q=; b=VCoUip4rXsgwHNiWUWaROpX8QxpqqRhLcaAtsTSBymnZRfyu0fbLjHd2MPRfWx2JFI SlB6mwGlvfsSnBabGCy9BopFhl8oSngs2Y5YjFsM/PgsBTdjvfUuc4hUihZgk7Dy3t/M iEgYaBOAwLrKq6WSaPOokdeNOm11rI5VkTJ54u8HxiUNaNX0h3DqXl/YCIAy1tJygOtD uRPAaysDcqEMQRJILsAuk9Ap/G1LToCLmi/CM3NfrwmmjhKa4N7fEP3p8vUwmogK8nvj 8Utvtju2+EIT/YeSogYJReHVJkq03RipVXaaegLjuIzCKJ+KJbWh9hPLKbBOZIJSH7Gv kskg== X-Gm-Message-State: ABUngvcU8tt3rG4gH70UPT+ZM4mHsDFg0TlAIpA+cZ+7gNixQ7JYQZ0lmvsQq3UL4zxvAf4Q X-Received: by 10.194.29.129 with SMTP id k1mr11453110wjh.120.1477661787309; Fri, 28 Oct 2016 06:36:27 -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 f194sm9037802wmg.12.2016.10.28.06.36.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 28 Oct 2016 06:36:26 -0700 (PDT) Date: Fri, 28 Oct 2016 14:36:25 +0100 From: Leif Lindholm To: Ard Biesheuvel Cc: edk2-devel@lists.01.org, lersek@redhat.com, ryan.harkin@linaro.org Message-ID: <20161028133625.GM1161@bivouac.eciton.net> References: <1477651478-16830-1-git-send-email-ard.biesheuvel@linaro.org> <1477651478-16830-6-git-send-email-ard.biesheuvel@linaro.org> MIME-Version: 1.0 In-Reply-To: <1477651478-16830-6-git-send-email-ard.biesheuvel@linaro.org> User-Agent: Mutt/1.5.23 (2014-03-12) 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:36:33 -0000 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 ? > + mTransport->Send (sizeof Response - 1, Response, &mFatalSendErrorEvent); > > mState = ExpectDataState; > mBytesReceivedSoFar = 0; > @@ -257,8 +259,7 @@ AcceptCmd ( > } > > // Commands aren't null-terminated. Let's get a null-terminated version. > - AsciiStrnCpy (Command, Data, Size); > - Command[Size] = '\0'; > + AsciiStrnCpyS (Command, sizeof Command, Data, Size); > > // Parse command > if (MATCH_CMD_LITERAL ("getvar", Command)) { > -- > 2.7.4 >