]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ShellPkg/UefiShellLevel2CommansLib: Pointer Resonse should be checked
authorGao, Zhichao <zhichao.gao@intel.com>
Mon, 12 Aug 2019 15:36:21 +0000 (08:36 -0700)
committerJaben Carsey <jaben.carsey@intel.com>
Tue, 13 Aug 2019 02:51:36 +0000 (19:51 -0700)
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>
ShellPkg/Library/UefiShellLevel2CommandsLib/Cp.c
ShellPkg/Library/UefiShellLevel2CommandsLib/Mv.c

index 18b05b580390c40c078d96b4808815247e19c8fd..4a2c2cfe641883f78ed3881e57c67392af9ceff3 100644 (file)
@@ -2,7 +2,7 @@
   Main file for cp shell level 2 function.\r
 \r
   (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>\r
-  Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2019, Intel Corporation. All rights reserved.<BR>\r
   SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
@@ -101,6 +101,9 @@ CopySingleFile(
     // possibly return based on response\r
     //\r
     if (!SilentMode) {\r
+      if (Response == NULL) {\r
+        return SHELL_ABORTED;\r
+      }\r
       switch (*(SHELL_PROMPT_RESPONSE*)Response) {\r
         case ShellPromptResponseNo:\r
           //\r
index 8c2852d7eb8d668f6f5e702296849b120f6c868a..f50c1e4c206f3d7788ba053b1d769650a8b2b783 100644 (file)
@@ -2,7 +2,7 @@
   Main file for mv shell level 2 function.\r
 \r
   (C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.<BR>\r
-  Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2019, Intel Corporation. All rights reserved.<BR>\r
   SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
@@ -637,6 +637,9 @@ ValidateAndMoveFiles(
       if (Response == NULL) {\r
         ShellPromptForResponseHii(ShellPromptResponseTypeYesNoAllCancel, STRING_TOKEN (STR_GEN_DEST_EXIST_OVR), gShellLevel2HiiHandle, &Response);\r
       }\r
+      if (Response == NULL) {\r
+        return SHELL_ABORTED;\r
+      }\r
       switch (*(SHELL_PROMPT_RESPONSE*)Response) {\r
         case ShellPromptResponseNo:\r
           FreePool(Response);\r