public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH] ShellPkg/for: Fix potential null pointer deference
@ 2018-02-05  7:53 Ruiyu Ni
  2018-02-05 14:59 ` Carsey, Jaben
  0 siblings, 1 reply; 2+ messages in thread
From: Ruiyu Ni @ 2018-02-05  7:53 UTC (permalink / raw)
  To: edk2-devel; +Cc: Jaben Carsey

When "FOR %a %a IN A B C" is executed,
CurrentScriptFile->CurrentCommand->Data is NULL.
But the code assumes it's not NULL and tries to
deference it.

The patch fixes this issue.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Jaben Carsey <jaben.carsey@intel.com>
---
 ShellPkg/Library/UefiShellLevel1CommandsLib/For.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/ShellPkg/Library/UefiShellLevel1CommandsLib/For.c b/ShellPkg/Library/UefiShellLevel1CommandsLib/For.c
index 3db4bb58d3..9824977149 100644
--- a/ShellPkg/Library/UefiShellLevel1CommandsLib/For.c
+++ b/ShellPkg/Library/UefiShellLevel1CommandsLib/For.c
@@ -2,7 +2,7 @@
   Main file for endfor and for shell level 1 functions.
 
   (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
-  Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2009 - 2018, 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
@@ -624,7 +624,9 @@ ShellCommandRunFor (
   if (CurrentScriptFile != NULL && CurrentScriptFile->CurrentCommand != NULL) {
     Info = (SHELL_FOR_INFO*)CurrentScriptFile->CurrentCommand->Data;
     if (CurrentScriptFile->CurrentCommand->Reset) {
-      Info->CurrentValue  = (CHAR16*)Info->Set;
+      if (Info != NULL) {
+        Info->CurrentValue = (CHAR16*)Info->Set;
+      }
       FirstPass = TRUE;
       CurrentScriptFile->CurrentCommand->Reset = FALSE;
     }
-- 
2.16.1.windows.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] ShellPkg/for: Fix potential null pointer deference
  2018-02-05  7:53 [PATCH] ShellPkg/for: Fix potential null pointer deference Ruiyu Ni
@ 2018-02-05 14:59 ` Carsey, Jaben
  0 siblings, 0 replies; 2+ messages in thread
From: Carsey, Jaben @ 2018-02-05 14:59 UTC (permalink / raw)
  To: Ni, Ruiyu, edk2-devel@lists.01.org

Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>

> -----Original Message-----
> From: Ni, Ruiyu
> Sent: Sunday, February 04, 2018 11:54 PM
> To: edk2-devel@lists.01.org
> Cc: Carsey, Jaben <jaben.carsey@intel.com>
> Subject: [PATCH] ShellPkg/for: Fix potential null pointer deference
> Importance: High
> 
> When "FOR %a %a IN A B C" is executed,
> CurrentScriptFile->CurrentCommand->Data is NULL.
> But the code assumes it's not NULL and tries to
> deference it.
> 
> The patch fixes this issue.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
> Cc: Jaben Carsey <jaben.carsey@intel.com>
> ---
>  ShellPkg/Library/UefiShellLevel1CommandsLib/For.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/ShellPkg/Library/UefiShellLevel1CommandsLib/For.c
> b/ShellPkg/Library/UefiShellLevel1CommandsLib/For.c
> index 3db4bb58d3..9824977149 100644
> --- a/ShellPkg/Library/UefiShellLevel1CommandsLib/For.c
> +++ b/ShellPkg/Library/UefiShellLevel1CommandsLib/For.c
> @@ -2,7 +2,7 @@
>    Main file for endfor and for shell level 1 functions.
> 
>    (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
> -  Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>
> +  Copyright (c) 2009 - 2018, 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
> @@ -624,7 +624,9 @@ ShellCommandRunFor (
>    if (CurrentScriptFile != NULL && CurrentScriptFile->CurrentCommand !=
> NULL) {
>      Info = (SHELL_FOR_INFO*)CurrentScriptFile->CurrentCommand->Data;
>      if (CurrentScriptFile->CurrentCommand->Reset) {
> -      Info->CurrentValue  = (CHAR16*)Info->Set;
> +      if (Info != NULL) {
> +        Info->CurrentValue = (CHAR16*)Info->Set;
> +      }
>        FirstPass = TRUE;
>        CurrentScriptFile->CurrentCommand->Reset = FALSE;
>      }
> --
> 2.16.1.windows.1



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-02-05 14:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-05  7:53 [PATCH] ShellPkg/for: Fix potential null pointer deference Ruiyu Ni
2018-02-05 14:59 ` Carsey, Jaben

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox