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 79D2A81D43 for ; Fri, 28 Oct 2016 02:28:32 -0700 (PDT) Received: by mail-wm0-x233.google.com with SMTP id n67so100870980wme.1 for ; Fri, 28 Oct 2016 02:28:32 -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=pHUfRU/NXFpiYZ2QG9JXqK9WA2i5nynk9yAW0DmrTkw=; b=hib+SI3EGdkAluWsMC9Uct34YFby6micfwkEXD3uTCocUehqiLuYZieyPzGcYybNFa B9udGsUjj0cOHnuIAvw7KSFlv0q6UVQTuyShwMlnWEvOlPStd7+vqqrU4/e5vPNP2WZh +Z0DCBgMnh4as6w/CxlF+ZGDwSRop3S5pgacg= 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=pHUfRU/NXFpiYZ2QG9JXqK9WA2i5nynk9yAW0DmrTkw=; b=GyHJ8PXjUu5Wz7keypPLLQOv6cyiwW4MC9zzAaPnp9jvRGDNhDnpwsAkZ8p7VTrWAr VAsAu71sES076mAdDqid/QQAFvYyU35VpD4BcHeNU52fyAqrLZ00+rIFi/t+viiH1agH JFQEYDY/WXz05LaVWfVf0BJ//mNSnitpfVPVjeZTvekwSzUMjO2a4mG16E6WegJ2AKb0 Q/XIBp1KhTMNy8B0fvXyAhWyMtkTkUJU7mQu9LmOFdnwmCk8YNs8EqERf57FXbv53OLa SnwuAjYtuQUhREm8/4uJiEu95N1+r0rerPALNOzYPljq2CJ28JYFVHmd8RpExHJQN0qV OLuA== X-Gm-Message-State: ABUngvfeffTIj1aEhgnqS41tD84OgAUaRuM1zbctVTbPbUFOdiwRdxAxDIFiwT20OTgN58dZ X-Received: by 10.28.158.209 with SMTP id h200mr2868811wme.54.1477646911457; Fri, 28 Oct 2016 02:28:31 -0700 (PDT) Received: from localhost.localdomain ([105.150.227.229]) by smtp.gmail.com with ESMTPSA id t129sm5074228wmg.23.2016.10.28.02.28.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 28 Oct 2016 02:28:30 -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 10:28:14 +0100 Message-Id: <1477646896-21444-5-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1477646896-21444-1-git-send-email-ard.biesheuvel@linaro.org> References: <1477646896-21444-1-git-send-email-ard.biesheuvel@linaro.org> Subject: [PATCH v3 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: Fri, 28 Oct 2016 09:28:32 -0000 Remove calls to deprecated string functions like AsciiStrCpy() and UnicodeStrToAsciiStr() Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel Reviewed-by: Laszlo Ersek Tested-by: Ryan Harkin --- 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..92aa5f8b0e4e 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, ResultSize); 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