summaryrefslogtreecommitdiff
path: root/ShellPkg/Library/UefiShellLib
diff options
context:
space:
mode:
authorRuiyu Ni <ruiyu.ni@intel.com>2018-11-07 17:34:20 +0800
committerRuiyu Ni <ruiyu.ni@intel.com>2018-11-08 10:25:53 +0800
commitb46de50913dea36d24637394c41d34095bfdaee2 (patch)
tree2e0e14b16105ad521da7cc3be312e865e3cb0bca /ShellPkg/Library/UefiShellLib
parente6459b9e6c9fc84414c87631df3662ce9cfbeabc (diff)
downloadedk2-b46de50913dea36d24637394c41d34095bfdaee2.zip
edk2-b46de50913dea36d24637394c41d34095bfdaee2.tar.gz
edk2-b46de50913dea36d24637394c41d34095bfdaee2.tar.bz2
ShellPkg/ShellLib: Fix potential NULL deference issue
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>
Diffstat (limited to 'ShellPkg/Library/UefiShellLib')
-rw-r--r--ShellPkg/Library/UefiShellLib/UefiShellLib.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/ShellPkg/Library/UefiShellLib/UefiShellLib.c b/ShellPkg/Library/UefiShellLib/UefiShellLib.c
index 580a1ee..b17266d 100644
--- a/ShellPkg/Library/UefiShellLib/UefiShellLib.c
+++ b/ShellPkg/Library/UefiShellLib/UefiShellLib.c
@@ -72,6 +72,7 @@ FullyQualifyPath(
{
CONST CHAR16 *WorkingPath;
CONST CHAR16 *InputPath;
+ CHAR16 *CharPtr;
CHAR16 *InputFileSystem;
UINTN FileSystemCharCount;
CHAR16 *FullyQualifiedPath;
@@ -131,7 +132,10 @@ FullyQualifyPath(
// truncate the new path after the file system part.
//
StrCpyS(FullyQualifiedPath, Size/sizeof(CHAR16), WorkingPath);
- *(StrStr(FullyQualifiedPath, L":") + 1) = CHAR_NULL;
+ CharPtr = StrStr(FullyQualifiedPath, L":");
+ if (CharPtr != NULL) {
+ *(CharPtr + 1) = CHAR_NULL;
+ }
} else {
//
// Relative path: start with the working directory and append "\".