ShellPkg/UefiShellLevel2CommansLib: Pointer Resonse should be checked

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2049

ShellPkg\Library\UefiShellLevel2CommandsLib\Cp.c line 104 and
ShellPkg\Library\UefiShellLevel2CommandsLib\Mv.c line 640, the
pointer variable Response may be a NULL pointer. So we should
make sure that it isn't NULL before dereference it.

If Response is NULL that indicates a EFI_OUT_OF_RESOURCES
error, directly return SHELL_ABORTED.

Cc: Jaben Carsey <jaben.carsey@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Signed-off-by: Zhichao Gao <zhichao.gao@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
This commit is contained in:
Gao, Zhichao
2019-08-12 08:36:21 -07:00
committed by Jaben Carsey
parent 48d5d6d5e0
commit 12dcad5b1e
2 changed files with 8 additions and 2 deletions

View File

@ -2,7 +2,7 @@
Main file for cp shell level 2 function. Main file for cp shell level 2 function.
(C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR> (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR> Copyright (c) 2009 - 2019, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent SPDX-License-Identifier: BSD-2-Clause-Patent
**/ **/
@ -101,6 +101,9 @@ CopySingleFile(
// possibly return based on response // possibly return based on response
// //
if (!SilentMode) { if (!SilentMode) {
if (Response == NULL) {
return SHELL_ABORTED;
}
switch (*(SHELL_PROMPT_RESPONSE*)Response) { switch (*(SHELL_PROMPT_RESPONSE*)Response) {
case ShellPromptResponseNo: case ShellPromptResponseNo:
// //

View File

@ -2,7 +2,7 @@
Main file for mv shell level 2 function. Main file for mv shell level 2 function.
(C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.<BR> (C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.<BR>
Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR> Copyright (c) 2009 - 2019, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent SPDX-License-Identifier: BSD-2-Clause-Patent
**/ **/
@ -637,6 +637,9 @@ ValidateAndMoveFiles(
if (Response == NULL) { if (Response == NULL) {
ShellPromptForResponseHii(ShellPromptResponseTypeYesNoAllCancel, STRING_TOKEN (STR_GEN_DEST_EXIST_OVR), gShellLevel2HiiHandle, &Response); ShellPromptForResponseHii(ShellPromptResponseTypeYesNoAllCancel, STRING_TOKEN (STR_GEN_DEST_EXIST_OVR), gShellLevel2HiiHandle, &Response);
} }
if (Response == NULL) {
return SHELL_ABORTED;
}
switch (*(SHELL_PROMPT_RESPONSE*)Response) { switch (*(SHELL_PROMPT_RESPONSE*)Response) {
case ShellPromptResponseNo: case ShellPromptResponseNo:
FreePool(Response); FreePool(Response);