From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.20; helo=mga02.intel.com; envelope-from=ruiyu.ni@intel.com; receiver=edk2-devel@lists.01.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 19B4A21A00AE6 for ; Wed, 7 Nov 2018 01:35:17 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Nov 2018 01:35:17 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,475,1534834800"; d="scan'208";a="98301843" Received: from ray-dev.ccr.corp.intel.com ([10.239.9.11]) by orsmga003.jf.intel.com with ESMTP; 07 Nov 2018 01:35:16 -0800 From: Ruiyu Ni To: edk2-devel@lists.01.org Cc: Jim Dailey , Hao A Wu Date: Wed, 7 Nov 2018 17:36:37 +0800 Message-Id: <20181107093637.168244-1-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.16.1.windows.1 Subject: [PATCH] ShellPkg/ShellLib: Fix potential NULL deference issue X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Nov 2018 09:35:18 -0000 Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni Cc: Jim Dailey Cc: Hao A Wu --- 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.16.1.windows.1