diff options
author | Jaben Carsey <Jaben.carsey@intel.com> | 2014-05-14 16:54:09 +0000 |
---|---|---|
committer | jcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524> | 2014-05-14 16:54:09 +0000 |
commit | 09a43a5d5ce9285b27551d7909f038e350b360d9 (patch) | |
tree | bd75fc1ba2cf32aa34b5ccfbad96c1690251f6b4 | |
parent | 271ce4bd70953bf4ca5be7db9d7e65e470384896 (diff) | |
download | edk2-09a43a5d5ce9285b27551d7909f038e350b360d9.zip edk2-09a43a5d5ce9285b27551d7909f038e350b360d9.tar.gz edk2-09a43a5d5ce9285b27551d7909f038e350b360d9.tar.bz2 |
ShellPkg: report error when EfiDecompress is run on a non-compressed file
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jaben Carsey <Jaben.carsey@intel.com>
Reviewed-by: Tapan Shah <tapandshah@hp.com>
Reviewed-by: Erik Bjorge <erik.c.bjorge@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15529 6f19259b-4bc3-4df7-8a09-765794883524
-rw-r--r-- | ShellPkg/Library/UefiShellDebug1CommandsLib/EfiDecompress.c | 54 | ||||
-rw-r--r-- | ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.uni | bin | 171002 -> 171274 bytes |
2 files changed, 29 insertions, 25 deletions
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/EfiDecompress.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/EfiDecompress.c index 35a32f1..bae4464 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/EfiDecompress.c +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/EfiDecompress.c @@ -1,7 +1,7 @@ /** @file
Main file for EfiDecompress shell Debug1 function.
- Copyright (c) 2005 - 2010, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2005 - 2014, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -110,11 +110,6 @@ ShellCommandRunEfiDecompress ( ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_OPEN_FAIL), gShellDebug1HiiHandle, ShellCommandLineGetRawValue(Package, 1), Status);
ShellStatus = SHELL_NOT_FOUND;
}
- Status = ShellOpenFileByName(OutFileName, &OutFileHandle, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE|EFI_FILE_MODE_CREATE, 0);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_OPEN_FAIL), gShellDebug1HiiHandle, ShellCommandLineGetRawValue(Package, 2), Status);
- ShellStatus = SHELL_NOT_FOUND;
- }
}
if (ShellStatus == SHELL_SUCCESS) {
@@ -131,27 +126,36 @@ ShellCommandRunEfiDecompress ( ASSERT_EFI_ERROR(Status);
Status = Decompress->GetInfo(Decompress, InBuffer, (UINT32)InSize, &OutSize, &ScratchSize);
- ASSERT_EFI_ERROR(Status);
-
- OutBuffer = AllocateZeroPool(OutSize);
- ScratchBuffer = AllocateZeroPool(ScratchSize);
- ASSERT(OutBuffer != NULL);
- ASSERT(ScratchBuffer != NULL);
-
- Status = Decompress->Decompress(Decompress, InBuffer, (UINT32)InSize, OutBuffer, OutSize, ScratchBuffer, ScratchSize);
- ASSERT_EFI_ERROR(Status);
-
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_EFI_DECOMPRESS_FAIL), gShellDebug1HiiHandle, Status);
- ShellStatus = SHELL_DEVICE_ERROR;
+ if (EFI_ERROR(Status) || OutSize == 0) {
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_EFI_DECOMPRESS_NOPE), gShellDebug1HiiHandle, InFileName);
+ ShellStatus = SHELL_NOT_FOUND;
} else {
- OutSizeTemp = OutSize;
- Status = gEfiShellProtocol->WriteFile(OutFileHandle, &OutSizeTemp, OutBuffer);
- OutSize = (UINT32)OutSizeTemp;
+ Status = ShellOpenFileByName(OutFileName, &OutFileHandle, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE|EFI_FILE_MODE_CREATE, 0);
if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_WRITE_FAIL), gShellDebug1HiiHandle, OutFileName, Status);
- ShellStatus = SHELL_DEVICE_ERROR;
- }
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_OPEN_FAIL), gShellDebug1HiiHandle, ShellCommandLineGetRawValue(Package, 2), Status);
+ ShellStatus = SHELL_NOT_FOUND;
+ } else {
+ OutBuffer = AllocateZeroPool(OutSize);
+ ScratchBuffer = AllocateZeroPool(ScratchSize);
+ ASSERT(OutBuffer != NULL);
+ ASSERT(ScratchBuffer != NULL);
+
+ Status = Decompress->Decompress(Decompress, InBuffer, (UINT32)InSize, OutBuffer, OutSize, ScratchBuffer, ScratchSize);
+ ASSERT_EFI_ERROR(Status);
+
+ if (EFI_ERROR(Status)) {
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_EFI_DECOMPRESS_FAIL), gShellDebug1HiiHandle, Status);
+ ShellStatus = SHELL_DEVICE_ERROR;
+ } else {
+ OutSizeTemp = OutSize;
+ Status = gEfiShellProtocol->WriteFile(OutFileHandle, &OutSizeTemp, OutBuffer);
+ OutSize = (UINT32)OutSizeTemp;
+ if (EFI_ERROR(Status)) {
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_WRITE_FAIL), gShellDebug1HiiHandle, OutFileName, Status);
+ ShellStatus = SHELL_DEVICE_ERROR;
+ }
+ }
+ }
}
}
}
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.uni b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.uni Binary files differindex 65d058f..eb38d40 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.uni +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.uni |