From b46de50913dea36d24637394c41d34095bfdaee2 Mon Sep 17 00:00:00 2001 From: Ruiyu Ni Date: Wed, 7 Nov 2018 17:34:20 +0800 Subject: [PATCH] ShellPkg/ShellLib: Fix potential NULL deference issue MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1310 Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni Cc: Jim Dailey Reviewed-by: Hao A Wu Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Jaben Carsey --- ShellPkg/Library/UefiShellLib/UefiShellLib.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ShellPkg/Library/UefiShellLib/UefiShellLib.c b/ShellPkg/Library/UefiShellLib/UefiShellLib.c index 580a1ee612..b17266d623 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 "\". -- 2.39.2