From d5e35fddec9389b50b362c84eda6b47975b99fa0 Mon Sep 17 00:00:00 2001 From: Laszlo Ersek Date: Fri, 6 Sep 2019 23:29:03 +0200 Subject: ShellPkg/UefiShellDebug1CommandsLib: fix ShellCloseFile() call In the FileBufferSave() function, we invoke ShellCloseFile() if "Directory 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 Reviewed-by: Philippe Mathieu-Daude Reviewed-by: Jaben Carsey Reviewed-by: Zhichao Gao --- 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 464f9de38e..fd324cc4a8 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/FileBuffer.c +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/FileBuffer.c @@ -1462,7 +1462,7 @@ FileBufferSave ( if (Info != NULL && Info->Attribute & EFI_FILE_DIRECTORY) { StatusBarSetStatusString (L"Directory Can Not Be Saved"); - ShellCloseFile(FileHandle); + ShellCloseFile (&FileHandle); FreePool(Info); return EFI_LOAD_ERROR; } -- cgit v1.2.3