From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (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 74A9121A16EC9 for ; Tue, 16 May 2017 00:49:03 -0700 (PDT) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 May 2017 00:49:03 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.38,348,1491289200"; d="scan'208";a="262111389" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by fmsmga004.fm.intel.com with ESMTP; 16 May 2017 00:49:03 -0700 Received: from fmsmsx152.amr.corp.intel.com (10.18.125.5) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 16 May 2017 00:49:02 -0700 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by FMSMSX152.amr.corp.intel.com (10.18.125.5) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 16 May 2017 00:49:02 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.178]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.217]) with mapi id 14.03.0319.002; Tue, 16 May 2017 15:49:00 +0800 From: "Ni, Ruiyu" To: Jeff Westfahl , "edk2-devel@lists.01.org" CC: "Kinney, Michael D" , "Carsey, Jaben" , "Gao, Liming" Thread-Topic: [edk2] [PATCH] MdePkg/BaseLib: Fix PathRemoveLastItem to ignore consecutive '\' Thread-Index: AQHSyzkCAiZGAtby+EKXj1rMBbzSDaH2moCg Date: Tue, 16 May 2017 07:48:59 +0000 Message-ID: <734D49CCEBEEF84792F5B80ED585239D5B94A668@SHSMSX104.ccr.corp.intel.com> References: <1d9b206d346af8fa90fda6b3cc4404a1f66f55d5.1494604752.git.jeff.westfahl@ni.com> In-Reply-To: <1d9b206d346af8fa90fda6b3cc4404a1f66f55d5.1494604752.git.jeff.westfahl@ni.com> Accept-Language: en-US, zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH] MdePkg/BaseLib: Fix PathRemoveLastItem to ignore consecutive '\' X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 May 2017 07:49:03 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Jeff, PathRemoveLastItem() is expected to be called after PathCleanUpDirectories(= ). E.g.: what should we expect PathRemoveLastItem() do for "fs0:\a\b\..\"? So PathRemoveLastItem() expects the incoming path is cleaned. Thanks/Ray > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of > Jeff Westfahl > Sent: Saturday, May 13, 2017 12:01 AM > To: edk2-devel@lists.01.org > Cc: Kinney, Michael D ; Ni, Ruiyu > ; Carsey, Jaben ; Gao, Liming > > Subject: [edk2] [PATCH] MdePkg/BaseLib: Fix PathRemoveLastItem to ignore > consecutive '\' >=20 > This patch makes PathRemoveLastItem ignore consecutive occurrences of > the '\' path separator. >=20 > Consider a path like "FS0:\ABC\DEF\\", noting the consecutive '\' path > separator characters at the end. The expected result of > PathRemoveLastItem on such a path is "FS0:\ABC\". However, what we get is > "FS0:\ABC\DEF\". >=20 > We can see the result of this behavior with 'ls' in the EFI shell. Go a c= ouple of > folders deep into a filesystem and try 'ls ..\..'. Here's an example, wit= h a > filesystem with folder ABC in the root, with subfolder DEF. >=20 > FS0:\ABC\DEF\> ls .. > Directory of: FS0:\ABC\ > 05/12/2017 15:46 8,192 . > 05/12/2017 15:46 0 .. > 05/12/2017 15:46 8,192 DEF > 0 File(s) 0 bytes > 3 Dir(s) > FS0:\ABC\DEF\> ls ..\.. > Directory of: FS0:\ABC\ > 05/12/2017 15:46 8,192 . > 05/12/2017 15:46 0 .. > 05/12/2017 15:46 8,192 DEF > 0 File(s) 0 bytes > 3 Dir(s) > fs0:\ABC\DEF\> >=20 > As you can see, 'ls ..\..' lists only the parent folder. This patch resol= ves the > issue so that 'ls ..\..' lists the grandparent folder. >=20 > Cc: Michael D Kinney > Cc: Liming Gao > Cc: Ruiyu Ni > Cc: Jaben Carsey > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Jeff Westfahl > --- > MdePkg/Library/BaseLib/FilePaths.c | 4 +--- > 1 file changed, 1 insertion(+), 3 deletions(-) >=20 > diff --git a/MdePkg/Library/BaseLib/FilePaths.c > b/MdePkg/Library/BaseLib/FilePaths.c > index 203045c..bbaf140 100644 > --- a/MdePkg/Library/BaseLib/FilePaths.c > +++ b/MdePkg/Library/BaseLib/FilePaths.c > @@ -37,9 +37,7 @@ PathRemoveLastItem( > ; Walker !=3D NULL && *Walker !=3D CHAR_NULL > ; Walker++ > ){ > - if (*Walker =3D=3D L'\\' && *(Walker + 1) !=3D CHAR_NULL) { > - LastSlash =3D Walker+1; > - } else if (*Walker =3D=3D L':' && *(Walker + 1) !=3D L'\\' && *(Walk= er + 1) !=3D > CHAR_NULL) { > + if ((*Walker =3D=3D L'\\' || *Walker =3D=3D L':') && *(Walker + 1) != =3D L'\\' > + && *(Walker + 1) !=3D CHAR_NULL) { > LastSlash =3D Walker+1; > } > } > -- > 2.7.4 >=20 > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel