From f9c3b1b5343f53705f1ab72c55c1db440b01f36f Mon Sep 17 00:00:00 2001 From: Vladimir Olovyannikov Date: Thu, 6 Oct 2016 15:02:26 -0700 Subject: ShellPkg: Fix erroneous Status returned by ShellOpenFileByName() In ShellOpenFileByName() the file is opened using gEfiShellProtocol->OpenFileByName(). It is supposed that if this call returns an EFI_ERROR, the function should return that error immediately. However, this return was missing, and if UnicodeCollationProtocol has not been located by this time, the Status gets overwritten with LocateProtocol() call result, which eventually erroneously returns EFI_SUCCESS to the Shell.c, and this leads to attempt to execute a non-existent startup script, which fails, and which in turn leads to Shell being unloaded with "Invalid parameter" error. This patch fixes the bug. Cc: Tapan Shah Cc: Jaben Carsey Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Vladimir Olovyannikov Reviewed-by: Tapan Shah Reviewed-by: Jaben Carsey --- ShellPkg/Library/UefiShellLib/UefiShellLib.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'ShellPkg/Library/UefiShellLib') diff --git a/ShellPkg/Library/UefiShellLib/UefiShellLib.c b/ShellPkg/Library/UefiShellLib/UefiShellLib.c index 53f54e1746..8db18b3b21 100644 --- a/ShellPkg/Library/UefiShellLib/UefiShellLib.c +++ b/ShellPkg/Library/UefiShellLib/UefiShellLib.c @@ -723,6 +723,9 @@ ShellOpenFileByName( Status = gEfiShellProtocol->OpenFileByName(FileName, FileHandle, OpenMode); + if (EFI_ERROR(Status)) { + return Status; + } if (mUnicodeCollationProtocol == NULL) { Status = gBS->LocateProtocol (&gEfiUnicodeCollation2ProtocolGuid, NULL, (VOID**)&mUnicodeCollationProtocol); -- cgit v1.2.3