diff options
author | Qiu Shumin <shumin.qiu@intel.com> | 2016-04-25 10:08:30 +0800 |
---|---|---|
committer | Qiu Shumin <shumin.qiu@intel.com> | 2016-04-26 14:37:50 +0800 |
commit | 91a92220f75c15950e5ba913c1f204ec73f2c2e9 (patch) | |
tree | 0b270db8a12fb4a1119b58d45888855423fa4eb5 /ShellPkg/Application/Shell/ShellProtocol.c | |
parent | 4a21fb3b67a0ef1655b43e9368b6b697bbf327af (diff) | |
download | edk2-platforms-91a92220f75c15950e5ba913c1f204ec73f2c2e9.tar.xz |
ShellPkg: Fix Shell treats every .EFI file as an executable application.
UEFI Shell 2.x cannot recognize whether a .EFI file is an application or
a driver. This means when we typed in a driver image in Shell command
line, Shell will load the driver image and try to run the entry point
function of the driver.
This patch check the ImageCodeType to fix the issue.
Cc: Jaben Carsey <jaben.carsey@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Qiu Shumin <shumin.qiu@intel.com>
Diffstat (limited to 'ShellPkg/Application/Shell/ShellProtocol.c')
-rw-r--r-- | ShellPkg/Application/Shell/ShellProtocol.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/ShellPkg/Application/Shell/ShellProtocol.c b/ShellPkg/Application/Shell/ShellProtocol.c index 17c30029e4..dc65b7d09a 100644 --- a/ShellPkg/Application/Shell/ShellProtocol.c +++ b/ShellPkg/Application/Shell/ShellProtocol.c @@ -1441,6 +1441,7 @@ InternalShellExecuteDevicePath( }
InitializeListHead(&OrigEnvs);
+ ZeroMem(&ShellParamsProtocol, sizeof(EFI_SHELL_PARAMETERS_PROTOCOL));
NewHandle = NULL;
@@ -1483,6 +1484,20 @@ InternalShellExecuteDevicePath( EFI_OPEN_PROTOCOL_GET_PROTOCOL);
if (!EFI_ERROR(Status)) {
+ //
+ // If the image is not an app abort it.
+ //
+ if (LoadedImage->ImageCodeType != EfiLoaderCode){
+ ShellPrintHiiEx(
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_SHELL_IMAGE_NOT_APP),
+ ShellInfoObject.HiiHandle
+ );
+ goto UnloadImage;
+ }
+
ASSERT(LoadedImage->LoadOptionsSize == 0);
if (NewCmdLine != NULL) {
LoadedImage->LoadOptionsSize = (UINT32)StrSize(NewCmdLine);
|