From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: redhat.com, ip: 209.132.183.28, mailfrom: lersek@redhat.com) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by groups.io with SMTP; Tue, 17 Sep 2019 12:50:41 -0700 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CD2A730860BD; Tue, 17 Sep 2019 19:50:40 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-120-37.rdu2.redhat.com [10.10.120.37]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9081B600C4; Tue, 17 Sep 2019 19:50:39 +0000 (UTC) From: "Laszlo Ersek" To: edk2-devel-groups-io Cc: Jaben Carsey , Ray Ni , Zhichao Gao Subject: [PATCH 31/35] ShellPkg/UefiShellDebug1CommandsLib: fix ShellCloseFile() call Date: Tue, 17 Sep 2019 21:49:31 +0200 Message-Id: <20190917194935.24322-32-lersek@redhat.com> In-Reply-To: <20190917194935.24322-1-lersek@redhat.com> References: <20190917194935.24322-1-lersek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Tue, 17 Sep 2019 19:50:40 +0000 (UTC) Content-Transfer-Encoding: quoted-printable In the FileBufferSave() function, we invoke ShellCloseFile() if "Director= y Can Not Be Saved". The ShellCloseFile() function takes a (SHELL_FILE_HANDLE*) parameter called "FileHandle", and correctly passes the de-referenced (*FileHandle) to EFI_SHELL_CLOSE_FILE, which takes a SHELL_FILE_HANDLE. However, FileBufferSave() passes SHELL_FILE_HANDLE to ShellCloseFile(), not the expected (SHELL_FILE_HANDLE*). Correct it. This fixes an actual bug that has remained hidden for two reasons: - pointer-to-VOID converts from/to any pointer-to-object type silently, - the bug is on an error path which has likely never fired in practice. Cc: Jaben Carsey Cc: Ray Ni Cc: Zhichao Gao Signed-off-by: Laszlo Ersek --- Notes: tested: edit (saving a file) ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/FileBuffer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/FileBuffer.= c b/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/FileBuffer.c index 464f9de38e52..fd324cc4a861 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/FileBuffer.c +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/FileBuffer.c @@ -1462,7 +1462,7 @@ FileBufferSave ( =20 if (Info !=3D NULL && Info->Attribute & EFI_FILE_DIRECTORY) { StatusBarSetStatusString (L"Directory Can Not Be Saved"); - ShellCloseFile(FileHandle); + ShellCloseFile (&FileHandle); FreePool(Info); return EFI_LOAD_ERROR; } --=20 2.19.1.3.g30247aa5d201