X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=ShellPkg%2FLibrary%2FUefiShellDebug1CommandsLib%2FEfiDecompress.c;h=28c37ee76985de1a12969e8c37c7f57ab1e13812;hb=ba30d5f0512196b1ee7b3d864f980e551da0ebf5;hp=6b6218e1c8b3bbb198d94a7d4d25d630e6180b71;hpb=4092a8f6d01ae22513dc0cf4b4ec547be265bbbf;p=mirror_edk2.git diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/EfiDecompress.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/EfiDecompress.c index 6b6218e1c8..28c37ee769 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/EfiDecompress.c +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/EfiDecompress.c @@ -1,8 +1,8 @@ /** @file Main file for EfiDecompress shell Debug1 function. - Copyright (c) 2015, Hewlett-Packard Development Company, L.P.
- Copyright (c) 2005 - 2014, Intel Corporation. All rights reserved.
+ (C) Copyright 2015 Hewlett-Packard Development Company, L.P.
+ Copyright (c) 2005 - 2016, Intel Corporation. All rights reserved.
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 @@ -52,6 +52,7 @@ ShellCommandRunEfiDecompress ( InFileName = NULL; OutFileName = NULL; OutSize = 0; + ScratchSize = 0; ShellStatus = SHELL_SUCCESS; Status = EFI_SUCCESS; OutBuffer = NULL; @@ -59,6 +60,7 @@ ShellCommandRunEfiDecompress ( ScratchBuffer = NULL; InFileHandle = NULL; OutFileHandle = NULL; + Decompress = NULL; // // initialize the shell lib (we must be in non-auto-init...) @@ -119,14 +121,18 @@ ShellCommandRunEfiDecompress ( InSize = (UINTN)Temp64Bit; ASSERT_EFI_ERROR(Status); InBuffer = AllocateZeroPool(InSize); - ASSERT(InBuffer != NULL); - Status = gEfiShellProtocol->ReadFile(InFileHandle, &InSize, InBuffer); - ASSERT_EFI_ERROR(Status); + if (InBuffer == NULL) { + Status = EFI_OUT_OF_RESOURCES; + } else { + Status = gEfiShellProtocol->ReadFile (InFileHandle, &InSize, InBuffer); + ASSERT_EFI_ERROR (Status); - Status = gBS->LocateProtocol(&gEfiDecompressProtocolGuid, NULL, (VOID**)&Decompress); - ASSERT_EFI_ERROR(Status); + Status = gBS->LocateProtocol (&gEfiDecompressProtocolGuid, NULL, (VOID**) &Decompress); + ASSERT_EFI_ERROR (Status); + + Status = Decompress->GetInfo (Decompress, InBuffer, (UINT32) InSize, &OutSize, &ScratchSize); + } - Status = Decompress->GetInfo(Decompress, InBuffer, (UINT32)InSize, &OutSize, &ScratchSize); if (EFI_ERROR(Status) || OutSize == 0) { ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_EFI_DECOMPRESS_NOPE), gShellDebug1HiiHandle, InFileName); ShellStatus = SHELL_NOT_FOUND; @@ -138,25 +144,25 @@ ShellCommandRunEfiDecompress ( } 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; + if (OutBuffer == NULL || ScratchBuffer == NULL) { + Status = EFI_OUT_OF_RESOURCES; } 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, L"efidecompress", OutFileName, Status); - ShellStatus = SHELL_DEVICE_ERROR; - } + Status = Decompress->Decompress (Decompress, InBuffer, (UINT32) InSize, OutBuffer, OutSize, ScratchBuffer, ScratchSize); } - } + } + } + + if (EFI_ERROR (Status)) { + ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_EFI_DECOMPRESS_FAIL), gShellDebug1HiiHandle, Status); + ShellStatus = ((Status == EFI_OUT_OF_RESOURCES) ? SHELL_OUT_OF_RESOURCES : 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, L"efidecompress", OutFileName, Status); + ShellStatus = SHELL_DEVICE_ERROR; + } } } }