]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ShellPkg/ShellLib: Fix potential NULL deference issue
authorRuiyu Ni <ruiyu.ni@intel.com>
Wed, 7 Nov 2018 09:34:20 +0000 (17:34 +0800)
committerRuiyu Ni <ruiyu.ni@intel.com>
Thu, 8 Nov 2018 02:25:53 +0000 (10:25 +0800)
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1310

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Jim Dailey <jim_dailey@dell.com>
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
ShellPkg/Library/UefiShellLib/UefiShellLib.c

index 580a1ee612d6c641d0e310b2ad7e630a5ad73732..b17266d623fe08b2c3c19fe97adaa2eb6c8070a3 100644 (file)
@@ -72,6 +72,7 @@ FullyQualifyPath(
 {\r
   CONST CHAR16         *WorkingPath;\r
   CONST CHAR16         *InputPath;\r
+  CHAR16               *CharPtr;\r
   CHAR16               *InputFileSystem;\r
   UINTN                FileSystemCharCount;\r
   CHAR16               *FullyQualifiedPath;\r
@@ -131,7 +132,10 @@ FullyQualifyPath(
         // truncate the new path after the file system part.\r
         //\r
         StrCpyS(FullyQualifiedPath, Size/sizeof(CHAR16), WorkingPath);\r
-        *(StrStr(FullyQualifiedPath, L":") + 1) = CHAR_NULL;\r
+        CharPtr = StrStr(FullyQualifiedPath, L":");\r
+        if (CharPtr != NULL) {\r
+          *(CharPtr + 1) = CHAR_NULL;\r
+        }\r
       } else {\r
         //\r
         // Relative path: start with the working directory and append "\".\r