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.31; helo=mga06.intel.com; envelope-from=hao.a.wu@intel.com; receiver=edk2-devel@lists.01.org Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) (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 31E6721A09130 for ; Wed, 7 Nov 2018 16:46:32 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Nov 2018 16:46:32 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,477,1534834800"; d="scan'208";a="247899225" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by orsmga004.jf.intel.com with ESMTP; 07 Nov 2018 16:46:32 -0800 Received: from fmsmsx101.amr.corp.intel.com (10.18.124.199) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.408.0; Wed, 7 Nov 2018 16:46:25 -0800 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by fmsmsx101.amr.corp.intel.com (10.18.124.199) with Microsoft SMTP Server (TLS) id 14.3.408.0; Wed, 7 Nov 2018 16:46:25 -0800 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.117]) by shsmsx102.ccr.corp.intel.com ([169.254.2.84]) with mapi id 14.03.0415.000; Thu, 8 Nov 2018 08:46:22 +0800 From: "Wu, Hao A" To: "Ni, Ruiyu" , "edk2-devel@lists.01.org" CC: Jim Dailey Thread-Topic: [PATCH] ShellPkg/ShellLib: Fix potential NULL deference issue Thread-Index: AQHUdn01m0f1TRI18kWSsW7/f63K/qVFC82w Date: Thu, 8 Nov 2018 00:46:21 +0000 Message-ID: References: <20181107093637.168244-1-ruiyu.ni@intel.com> In-Reply-To: <20181107093637.168244-1-ruiyu.ni@intel.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [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: Thu, 08 Nov 2018 00:46:33 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable > -----Original Message----- > From: Ni, Ruiyu > Sent: Wednesday, November 07, 2018 5:37 PM > To: edk2-devel@lists.01.org > Cc: Jim Dailey; Wu, Hao A > Subject: [PATCH] ShellPkg/ShellLib: Fix potential NULL deference issue >=20 > 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(-) >=20 > 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) =3D CHAR_NULL; > + CharPtr =3D StrStr(FullyQualifiedPath, L":"); > + if (CharPtr !=3D NULL) { > + *(CharPtr + 1) =3D CHAR_NULL; > + } > } else { > // > // Relative path: start with the working directory and append "\= ". > -- Reviewed-by: Hao Wu Best Regards, Hao Wu > 2.16.1.windows.1