From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-x233.google.com (mail-wm0-x233.google.com [IPv6:2a00:1450:400c:c09::233]) (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 9DDA381D59 for ; Fri, 28 Oct 2016 03:44:57 -0700 (PDT) Received: by mail-wm0-x233.google.com with SMTP id 140so12474468wmv.1 for ; Fri, 28 Oct 2016 03:44:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=E1VU49T8O8vpoOmJLJJpQqsr/BJDtmu14kNYMn7JPmE=; b=M7oTGuo23B/0S3MUUyft7U5d+a4zur8mt9ik0pNX3WNEI6nKvwg8p4a8luerZz6G5E RE+VE0aP+vXLMhJNkvFqHTdy2q5vcHgcGbsx8HU5D8y8p9WHEeWsj6wjroLwLCN47sN2 AfRMik+Vp7yWPk+wSMm4w9UTEm+136/i2TXYI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=E1VU49T8O8vpoOmJLJJpQqsr/BJDtmu14kNYMn7JPmE=; b=YUNT+tgWzKkhM6Zfb3GnAT2wl6P7ssyULDLlvr8zLhGF/2fGOtTXkbZ3z6+5iMou9b n24h3wT2AwtTMar13UvuK8JEG1txta2h9DKZMHO+1MjnDPyen2Bg7PDm03XRyj1zfIlX PLX/Iwdh/0eX1fBVTNxCexSqZyQ52gZ91MrBRY0xANZwwn3W4PPJrpJvXy+zOCTgAt2q ZZc0+bRLbPJGBDSqeMRbndMH4DnO+dNlWUJUlSiUE4z+9uXMrogE0nnMTzhlxdIFqGlC dUQnJG3mNpEQuAlgEaARV6ajF5ZY/85lUVq+pvXWk6xhxdGOboUEyHbJpffLUBpmUCRc ELEA== X-Gm-Message-State: ABUngvdxF5gFpEN2vJciNS2VU1TM1byhK4mc+rFpkF1xCgrEcg8DSmaOSNdea4/CypoVkAQj X-Received: by 10.28.148.200 with SMTP id w191mr2018357wmd.43.1477651496662; Fri, 28 Oct 2016 03:44:56 -0700 (PDT) Received: from localhost.localdomain ([105.150.227.229]) by smtp.gmail.com with ESMTPSA id 184sm57730wms.4.2016.10.28.03.44.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 28 Oct 2016 03:44:56 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org, leif.lindholm@linaro.org Cc: lersek@redhat.com, ryan.harkin@linaro.org, Ard Biesheuvel Date: Fri, 28 Oct 2016 11:44:34 +0100 Message-Id: <1477651478-16830-6-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1477651478-16830-1-git-send-email-ard.biesheuvel@linaro.org> References: <1477651478-16830-1-git-send-email-ard.biesheuvel@linaro.org> Subject: [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 10:44:58 -0000 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); + 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