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
This commit is contained in:
Jaben Carsey 2014-05-14 16:54:09 +00:00 committed by jcarsey
parent 271ce4bd70
commit 09a43a5d5c
2 changed files with 29 additions and 25 deletions

View File

@ -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,8 +126,15 @@ ShellCommandRunEfiDecompress (
ASSERT_EFI_ERROR(Status);
Status = Decompress->GetInfo(Decompress, InBuffer, (UINT32)InSize, &OutSize, &ScratchSize);
ASSERT_EFI_ERROR(Status);
if (EFI_ERROR(Status) || OutSize == 0) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_EFI_DECOMPRESS_NOPE), gShellDebug1HiiHandle, InFileName);
ShellStatus = SHELL_NOT_FOUND;
} else {
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;
} else {
OutBuffer = AllocateZeroPool(OutSize);
ScratchBuffer = AllocateZeroPool(ScratchSize);
ASSERT(OutBuffer != NULL);
@ -156,6 +158,8 @@ ShellCommandRunEfiDecompress (
}
}
}
}
}
ShellCommandLineFreeVarList (Package);
}