From patchwork Mon Oct 24 16:06:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 78991 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp2658655qge; Mon, 24 Oct 2016 09:07:13 -0700 (PDT) X-Received: by 10.107.171.194 with SMTP id u185mr13293119ioe.102.1477325233256; Mon, 24 Oct 2016 09:07:13 -0700 (PDT) Return-Path: Received: from ml01.01.org (ml01.01.org. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id c4si1504160paz.118.2016.10.24.09.07.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 24 Oct 2016 09:07:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 8D3511A1E93; Mon, 24 Oct 2016 09:07:09 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received: from mail-wm0-x232.google.com (mail-wm0-x232.google.com [IPv6:2a00:1450:400c:c09::232]) (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 CA9EE1A1E73 for ; Mon, 24 Oct 2016 09:07:06 -0700 (PDT) Received: by mail-wm0-x232.google.com with SMTP id c78so111955897wme.0 for ; Mon, 24 Oct 2016 09:07:06 -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=q9asOq27sF/oOmOaW7Kc+DdMlNzKy6R7bCEYvcHWJ3s=; b=cynAu55HUNeyk7QULpqdrhnj/SDKqokN8pbuh0U9eUye+XdrVQXNrnjT1pudnC2UyA f68kiTB0Z0E05ytUeSjs+137IE2DL5fxQctJ0rRN6FohCGlQ61v+xkPkEhk59wzEOdiN gZ4HQtHEe4VUZWfuX/bSKV4+ibHnPFweZlEbU= 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=q9asOq27sF/oOmOaW7Kc+DdMlNzKy6R7bCEYvcHWJ3s=; b=aMkH9ZrU6HyTVMozq6N0+9QuUe4BDexPiG5Rdi9tsQ3+S8inI3afLxtkZ/SQ+zb3YM rOuWl23/qHKhR0q2qFZtGALNyd4h9i7wWLLGrMAeFHzYvnCT8YnGrjvn9EwDyHLonqIY ttS5NjI2RTn/rwx6t+//jHmIq3D/MhruCV+BqoszuRasSbGenCK3mjlbINgOIkR8fZBM aqevXPvJMC+fQz9nVQxPJalSFb0PwfgaJrW5BgmlgeUYpDnfjNQNGxIQ+laoZGtKXldE kEdkJKFvmOtZPgK/Eg/s6w6RoRLkJx9T9KtdM0zn5lafp8LUouHkEHV9aPyf2JMHD4YA oDXQ== X-Gm-Message-State: ABUngvdBRCg3CVk0tqwHuR8G0UjdYLBAQbTx1McJC6nbfWpfGzvm0p6xEfI49HTsSANDgpk5 X-Received: by 10.194.223.97 with SMTP id qt1mr12136222wjc.33.1477325225295; Mon, 24 Oct 2016 09:07:05 -0700 (PDT) Received: from localhost.localdomain ([105.146.229.54]) by smtp.gmail.com with ESMTPSA id h3sm20055144wjp.45.2016.10.24.09.07.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 24 Oct 2016 09:07:04 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org, leif.lindholm@linaro.org, lersek@redhat.com Date: Mon, 24 Oct 2016 17:06:44 +0100 Message-Id: <1477325206-24646-5-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1477325206-24646-1-git-send-email-ard.biesheuvel@linaro.org> References: <1477325206-24646-1-git-send-email-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH 4/6] ArmPkg/SemihostFs: 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: , Cc: Ard Biesheuvel MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" Remove calls to deprecated string functions like AsciiStrCpy() and UnicodeStrToAsciiStr() Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel --- ArmPkg/Filesystem/SemihostFs/Arm/SemihostFs.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) -- 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/ArmPkg/Filesystem/SemihostFs/Arm/SemihostFs.c b/ArmPkg/Filesystem/SemihostFs/Arm/SemihostFs.c index 6efdad9ebcce..e79b5cc5cf39 100644 --- a/ArmPkg/Filesystem/SemihostFs/Arm/SemihostFs.c +++ b/ArmPkg/Filesystem/SemihostFs/Arm/SemihostFs.c @@ -207,11 +207,12 @@ FileOpen ( return EFI_WRITE_PROTECTED; } - AsciiFileName = AllocatePool (StrLen (FileName) + 1); + Length = StrLen (FileName) + 1; + AsciiFileName = AllocatePool (Length); if (AsciiFileName == NULL) { return EFI_OUT_OF_RESOURCES; } - UnicodeStrToAsciiStr (FileName, AsciiFileName); + UnicodeStrToAsciiStrS (FileName, AsciiFileName, Length); // Opening '/', '\', '.', or the NULL pathname is trying to open the root directory if ((AsciiStrCmp (AsciiFileName, "\\") == 0) || @@ -463,7 +464,7 @@ FileDelete ( NameSize = AsciiStrLen (Fcb->FileName); FileName = AllocatePool (NameSize + 1); - AsciiStrCpy (FileName, Fcb->FileName); + AsciiStrCpyS (FileName, NameSize + 1, Fcb->FileName); // Close the file if it's open. Disregard return status, // since it might give an error if the file isn't open. @@ -828,8 +829,10 @@ GetFilesystemInfo ( EFI_FILE_SYSTEM_INFO *Info; EFI_STATUS Status; UINTN ResultSize; + UINTN StringSize; - ResultSize = SIZE_OF_EFI_FILE_SYSTEM_INFO + StrSize (mSemihostFsLabel); + StringSize = StrSize (mSemihostFsLabel); + ResultSize = SIZE_OF_EFI_FILE_SYSTEM_INFO + StringSize; if (*BufferSize >= ResultSize) { ZeroMem (Buffer, ResultSize); @@ -843,7 +846,7 @@ GetFilesystemInfo ( Info->FreeSpace = 0; Info->BlockSize = 0; - StrCpy (Info->VolumeLabel, mSemihostFsLabel); + StrCpyS (Info->VolumeLabel, StringSize, mSemihostFsLabel); } else { Status = EFI_BUFFER_TOO_SMALL; } @@ -903,7 +906,7 @@ FileGetInfo ( ResultSize = StrSize (mSemihostFsLabel); if (*BufferSize >= ResultSize) { - StrCpy (Buffer, mSemihostFsLabel); + StrCpyS (Buffer, *BufferSize, mSemihostFsLabel); Status = EFI_SUCCESS; } else { Status = EFI_BUFFER_TOO_SMALL; @@ -963,11 +966,12 @@ SetFileInfo ( return EFI_ACCESS_DENIED; } - AsciiFileName = AllocatePool (StrLen (Info->FileName) + 1); + Length = StrLen (Info->FileName) + 1; + AsciiFileName = AllocatePool (Length); if (AsciiFileName == NULL) { return EFI_OUT_OF_RESOURCES; } - UnicodeStrToAsciiStr (Info->FileName, AsciiFileName); + UnicodeStrToAsciiStrS (Info->FileName, AsciiFileName, Length); FileSizeIsDifferent = (Info->FileSize != Fcb->Info.FileSize); FileNameIsDifferent = (AsciiStrCmp (AsciiFileName, Fcb->FileName) != 0);