From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-x234.google.com (mail-wm0-x234.google.com [IPv6:2a00:1450:400c:c09::234]) (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 D21E01A1E8C for ; Wed, 26 Oct 2016 01:17:59 -0700 (PDT) Received: by mail-wm0-x234.google.com with SMTP id b80so210303689wme.1 for ; Wed, 26 Oct 2016 01:17:59 -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=q651vrQg/bl2uIZ83Et5Qb/IzhK/PnUWXMLkSp2v/Pc=; b=WPn+xrUdt85RZvRziQpHQNy/r7n7gVSR/aALFTM6vYi2dVGlhPs9TtncPrqqvgUT1U 7/y0lZfeeC29Kyr3R/JEx6lMLGPW9zVAPe5IVyKYaDDDj/EJhbOggAN02bqNrJFafLf/ K/qHIoKir5i4D/xo/8QRtwfFp0gO46pR/G7H8= 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=q651vrQg/bl2uIZ83Et5Qb/IzhK/PnUWXMLkSp2v/Pc=; b=a+Wn5z7Mn5LiiSI6oqVitJCNfQ4ud9Bd/osbgjx67qFZNB55g1WEw7WpenK8D9VPxs /DQbDQuYLg5T+rwTVf+b5bzJBFNJBvLbIX7rSxUxQ9K5hWEBVgCd2PnMiaBDEIhmXB+G 1lfXFz6aH0RhX5Qkxb4t1cjDtt6vhsXyg1U4WjUBIbQVeJF0f2/VqW2RceC7PM8cEvFj 2Y7WNpMFW9m4kM2Cbbs0AwLAwA4n8kQlFXtfpahxr52/fYapTkLAPwJcE9UtnO8TB8Nd E+yHyIiKaNWLkbZC2NViypgf0EdH6HVxa60BsI7YyGq7xMPI+z/bJdO+JNLGqxq5a50M vQyA== X-Gm-Message-State: ABUngvdOlQMs1iMubpOY0GdM78WZyzx1vTrXs59I3W/R3mx38nVw7KvxtWfpL8/RpOSLP4Bs X-Received: by 10.194.119.162 with SMTP id kv2mr993791wjb.182.1477469877247; Wed, 26 Oct 2016 01:17:57 -0700 (PDT) Received: from localhost.localdomain ([105.150.227.229]) by smtp.gmail.com with ESMTPSA id y2sm1166640wjx.20.2016.10.26.01.17.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 26 Oct 2016 01:17: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: Wed, 26 Oct 2016 09:17:40 +0100 Message-Id: <1477469862-10046-5-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1477469862-10046-1-git-send-email-ard.biesheuvel@linaro.org> References: <1477469862-10046-1-git-send-email-ard.biesheuvel@linaro.org> Subject: [PATCH v2 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: , X-List-Received-Date: Wed, 26 Oct 2016 08:18:00 -0000 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(-) diff --git a/ArmPkg/Filesystem/SemihostFs/Arm/SemihostFs.c b/ArmPkg/Filesystem/SemihostFs/Arm/SemihostFs.c index 6efdad9ebcce..cf94ecd5d56f 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); + CopyMem (Info->VolumeLabel, mSemihostFsLabel, StringSize); } else { Status = EFI_BUFFER_TOO_SMALL; } @@ -903,7 +906,7 @@ FileGetInfo ( ResultSize = StrSize (mSemihostFsLabel); if (*BufferSize >= ResultSize) { - StrCpy (Buffer, mSemihostFsLabel); + CopyMem (Buffer, mSemihostFsLabel, *BufferSize); 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); -- 2.7.4