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>
This commit is contained in:
Ruiyu Ni
2018-11-07 17:34:20 +08:00
parent e6459b9e6c
commit b46de50913

View File

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