[edk2-devel] [PATCH] ShellPkg/UefiShellLevel2CommansLib: Pointer Resonse should be checked

Gao, Zhichao posted 1 patch 17 weeks ago
Failed in applying to current master (apply log)
ShellPkg/Library/UefiShellLevel2CommandsLib/Cp.c | 5 ++++-
ShellPkg/Library/UefiShellLevel2CommandsLib/Mv.c | 5 ++++-
2 files changed, 8 insertions(+), 2 deletions(-)

[edk2-devel] [PATCH] ShellPkg/UefiShellLevel2CommansLib: Pointer Resonse should be checked

Posted by Gao, Zhichao 17 weeks ago
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>
---
 ShellPkg/Library/UefiShellLevel2CommandsLib/Cp.c | 5 ++++-
 ShellPkg/Library/UefiShellLevel2CommandsLib/Mv.c | 5 ++++-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Cp.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/Cp.c
index 18b05b5803..4a2c2cfe64 100644
--- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Cp.c
+++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Cp.c
@@ -2,7 +2,7 @@
   Main file for cp shell level 2 function.
 
   (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
 
 **/
@@ -101,6 +101,9 @@ CopySingleFile(
     // possibly return based on response
     //
     if (!SilentMode) {
+      if (Response == NULL) {
+        return SHELL_ABORTED;
+      }
       switch (*(SHELL_PROMPT_RESPONSE*)Response) {
         case ShellPromptResponseNo:
           //
diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Mv.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/Mv.c
index 8c2852d7eb..f50c1e4c20 100644
--- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Mv.c
+++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Mv.c
@@ -2,7 +2,7 @@
   Main file for mv shell level 2 function.
 
   (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
 
 **/
@@ -637,6 +637,9 @@ ValidateAndMoveFiles(
       if (Response == NULL) {
         ShellPromptForResponseHii(ShellPromptResponseTypeYesNoAllCancel, STRING_TOKEN (STR_GEN_DEST_EXIST_OVR), gShellLevel2HiiHandle, &Response);
       }
+      if (Response == NULL) {
+        return SHELL_ABORTED;
+      }
       switch (*(SHELL_PROMPT_RESPONSE*)Response) {
         case ShellPromptResponseNo:
           FreePool(Response);
-- 
2.21.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#45326): https://edk2.groups.io/g/devel/message/45326
Mute This Topic: https://groups.io/mt/32835761/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-

Re: [edk2-devel] [PATCH] ShellPkg/UefiShellLevel2CommansLib: Pointer Resonse should be checked

Posted by Carsey, Jaben 17 weeks ago
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>

Thanks
-Jaben

> -----Original Message-----
> From: Gao, Zhichao
> Sent: Sunday, August 11, 2019 5:36 PM
> To: devel@edk2.groups.io
> Cc: Carsey, Jaben <jaben.carsey@intel.com>; Ni, Ray <ray.ni@intel.com>
> Subject: [PATCH] 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>
> ---
>  ShellPkg/Library/UefiShellLevel2CommandsLib/Cp.c | 5 ++++-
>  ShellPkg/Library/UefiShellLevel2CommandsLib/Mv.c | 5 ++++-
>  2 files changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Cp.c
> b/ShellPkg/Library/UefiShellLevel2CommandsLib/Cp.c
> index 18b05b5803..4a2c2cfe64 100644
> --- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Cp.c
> +++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Cp.c
> @@ -2,7 +2,7 @@
>    Main file for cp shell level 2 function.
> 
>    (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
> 
>  **/
> @@ -101,6 +101,9 @@ CopySingleFile(
>      // possibly return based on response
>      //
>      if (!SilentMode) {
> +      if (Response == NULL) {
> +        return SHELL_ABORTED;
> +      }
>        switch (*(SHELL_PROMPT_RESPONSE*)Response) {
>          case ShellPromptResponseNo:
>            //
> diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Mv.c
> b/ShellPkg/Library/UefiShellLevel2CommandsLib/Mv.c
> index 8c2852d7eb..f50c1e4c20 100644
> --- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Mv.c
> +++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Mv.c
> @@ -2,7 +2,7 @@
>    Main file for mv shell level 2 function.
> 
>    (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
> 
>  **/
> @@ -637,6 +637,9 @@ ValidateAndMoveFiles(
>        if (Response == NULL) {
>          ShellPromptForResponseHii(ShellPromptResponseTypeYesNoAllCancel,
> STRING_TOKEN (STR_GEN_DEST_EXIST_OVR), gShellLevel2HiiHandle,
> &Response);
>        }
> +      if (Response == NULL) {
> +        return SHELL_ABORTED;
> +      }
>        switch (*(SHELL_PROMPT_RESPONSE*)Response) {
>          case ShellPromptResponseNo:
>            FreePool(Response);
> --
> 2.21.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#45453): https://edk2.groups.io/g/devel/message/45453
Mute This Topic: https://groups.io/mt/32835761/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-