[edk2] [PATCH] ShellPkg/Shell: Avoid potential null pointer deference

Ruiyu Ni posted 1 patch 7 years, 7 months ago
Failed in applying to current master (apply log)
ShellPkg/Application/Shell/Shell.c | 6 ++++++
1 file changed, 6 insertions(+)
[edk2] [PATCH] ShellPkg/Shell: Avoid potential null pointer deference
Posted by Ruiyu Ni 7 years, 7 months ago
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
---
 ShellPkg/Application/Shell/Shell.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/ShellPkg/Application/Shell/Shell.c b/ShellPkg/Application/Shell/Shell.c
index dfcbfb8..af8e523 100644
--- a/ShellPkg/Application/Shell/Shell.c
+++ b/ShellPkg/Application/Shell/Shell.c
@@ -1162,6 +1162,12 @@ LocateStartupScript (
   MapName = ShellInfoObject.NewEfiShellProtocol->GetMapFromDevicePath (&ImageDevicePath);
   if (MapName != NULL) {   
     StartupScriptPath = StrnCatGrow (&StartupScriptPath, &Size, MapName, 0);
+    if (StartupScriptPath == NULL) {
+      //
+      // Do not locate the startup script in sys path when out of resource.
+      //
+      return NULL;
+    }
     TempSpot = StrStr (StartupScriptPath, L";");
     if (TempSpot != NULL) {
       *TempSpot = CHAR_NULL;
-- 
2.9.0.windows.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
Re: [edk2] [PATCH] ShellPkg/Shell: Avoid potential null pointer deference
Posted by Wu, Hao A 7 years, 7 months ago
Reviewed-by: Hao Wu <hao.a.wu@intel.com>

Best Regards,
Hao Wu


> -----Original Message-----
> From: Ni, Ruiyu
> Sent: Tuesday, March 28, 2017 10:27 AM
> To: edk2-devel@lists.01.org
> Cc: Wu, Hao A
> Subject: [PATCH] ShellPkg/Shell: Avoid potential null pointer deference
> 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
> Cc: Hao A Wu <hao.a.wu@intel.com>
> ---
>  ShellPkg/Application/Shell/Shell.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/ShellPkg/Application/Shell/Shell.c
> b/ShellPkg/Application/Shell/Shell.c
> index dfcbfb8..af8e523 100644
> --- a/ShellPkg/Application/Shell/Shell.c
> +++ b/ShellPkg/Application/Shell/Shell.c
> @@ -1162,6 +1162,12 @@ LocateStartupScript (
>    MapName = ShellInfoObject.NewEfiShellProtocol->GetMapFromDevicePath
> (&ImageDevicePath);
>    if (MapName != NULL) {
>      StartupScriptPath = StrnCatGrow (&StartupScriptPath, &Size, MapName, 0);
> +    if (StartupScriptPath == NULL) {
> +      //
> +      // Do not locate the startup script in sys path when out of resource.
> +      //
> +      return NULL;
> +    }
>      TempSpot = StrStr (StartupScriptPath, L";");
>      if (TempSpot != NULL) {
>        *TempSpot = CHAR_NULL;
> --
> 2.9.0.windows.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel