From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-x22c.google.com (mail-wm0-x22c.google.com [IPv6:2a00:1450:400c:c09::22c]) (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 63EF481D2B for ; Fri, 28 Oct 2016 03:52:55 -0700 (PDT) Received: by mail-wm0-x22c.google.com with SMTP id e69so92062338wmg.0 for ; Fri, 28 Oct 2016 03:52:55 -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=z2C7SZpN9Len5fGf3wCO4aLF3HMJwr3YPyWYjM57uKc=; b=il5slB7OlZo0WYC0yAeIwsTwIB4wSbVS23QuX51NkYDCNDaEBy1aC5Kfst4E/8c0p9 N2TZJPJf0uuVMQbUir8xk+rJCJx1oGZuIXfQgh+eihoS86XH3MAc983REDsAKtt97Tyn v2QyfMbfneX4ZPnPSqea/uOrFQHM+a18RtIwg= 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=z2C7SZpN9Len5fGf3wCO4aLF3HMJwr3YPyWYjM57uKc=; b=BG3DenYY+dwU11X9fnYEi52QQ1+EQJ0YfUwpdsLTpn7TcjUxndG07Ad5XtJyHQHu0E tlckWDHzwCxSAJ9F3Nsq2I0NY8yEN2U+yF+gA4PvS7jbmj6Y8+/vsuh30QhrS8Sltx0v jgatikt/xRUb4aRosoRk8IGAG2BCtF6KtsLoVJ6Ae475agDbWbyTdH0nkLa9Jh2VSvVW 672wMDotnuF/sVdHYdbQjN2tbCRKyEfffFHzPkzkLC5DeCRF0JXcsfX4RtCy8sqMAL5W Lz8Sq6NNnF8eW3aQFbnrMLpOwgZKlWLeQ9Tdsd0hCP/+n0276ZTlfYSWyVsx5m4nv6Vl 24Yg== X-Gm-Message-State: ABUngvctiwA9JtEOZWvkBYzugLLVP04U9Jc1VG7fpt2ZSSOb0qDW6cj0DVexbhzITPiBXdwg X-Received: by 10.28.130.210 with SMTP id e201mr2122471wmd.118.1477651974459; Fri, 28 Oct 2016 03:52:54 -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 e2sm13478592wjw.14.2016.10.28.03.52.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 28 Oct 2016 03:52:53 -0700 (PDT) Date: Fri, 28 Oct 2016 11:52:52 +0100 From: Leif Lindholm To: Ard Biesheuvel Cc: edk2-devel@lists.01.org, lersek@redhat.com, ryan.harkin@linaro.org Message-ID: <20161028105252.GE1161@bivouac.eciton.net> References: <1477646896-21444-1-git-send-email-ard.biesheuvel@linaro.org> <1477646896-21444-5-git-send-email-ard.biesheuvel@linaro.org> MIME-Version: 1.0 In-Reply-To: <1477646896-21444-5-git-send-email-ard.biesheuvel@linaro.org> User-Agent: Mutt/1.5.23 (2014-03-12) Subject: Re: [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 10:52:55 -0000 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Fri, Oct 28, 2016 at 10:28:14AM +0100, Ard Biesheuvel wrote: > 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 Reviewed-by: Leif Lindholm > --- > 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 >