From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0b-00010702.pphosted.com (mx0a-00010702.pphosted.com [148.163.156.75]) (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 61D3321A04E19 for ; Fri, 12 May 2017 09:00:55 -0700 (PDT) Received: from pps.filterd (m0098780.ppops.net [127.0.0.1]) by mx0a-00010702.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v4CFtwtR003459; Fri, 12 May 2017 11:00:53 -0500 Received: from ni.com (skprod2.natinst.com [130.164.80.23]) by mx0a-00010702.pphosted.com with ESMTP id 2add7ngqrh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 May 2017 11:00:53 -0500 Received: from us-aus-exch2.ni.corp.natinst.com (us-aus-exch2.ni.corp.natinst.com [130.164.68.12]) by us-aus-skprod2.natinst.com (8.16.0.17/8.16.0.17) with ESMTPS id v4CG0p4Q004397 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Fri, 12 May 2017 11:00:52 -0500 Received: from us-aus-exch3.ni.corp.natinst.com (130.164.68.13) by us-aus-exch2.ni.corp.natinst.com (130.164.68.12) with Microsoft SMTP Server (TLS) id 15.0.1156.6; Fri, 12 May 2017 11:00:51 -0500 Received: from us-aus-exhub1.ni.corp.natinst.com (130.164.68.41) by us-aus-exch3.ni.corp.natinst.com (130.164.68.13) with Microsoft SMTP Server (TLS) id 15.0.1156.6; Fri, 12 May 2017 11:00:51 -0500 Received: from jmw-lm181.ni.corp.natinst.com (130.164.49.7) by us-aus-exhub1.ni.corp.natinst.com (130.164.68.41) with Microsoft SMTP Server id 15.0.1156.6 via Frontend Transport; Fri, 12 May 2017 11:00:51 -0500 From: Jeff Westfahl To: CC: Jeff Westfahl , Michael D Kinney , Liming Gao , Ruiyu Ni , Jaben Carsey Date: Fri, 12 May 2017 11:00:44 -0500 Message-ID: <1d9b206d346af8fa90fda6b3cc4404a1f66f55d5.1494604752.git.jeff.westfahl@ni.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-05-12_08:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_policy_notspam policy=outbound_policy score=30 priorityscore=1501 malwarescore=0 suspectscore=4 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=30 reason=mlx scancount=1 engine=8.0.1-1703280000 definitions=main-1705120300 Subject: [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: Fri, 12 May 2017 16:00:55 -0000 Content-Type: text/plain This patch makes PathRemoveLastItem ignore consecutive occurrences of the '\' path separator. 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\". We can see the result of this behavior with 'ls' in the EFI shell. Go a couple of folders deep into a filesystem and try 'ls ..\..'. Here's an example, with a filesystem with folder ABC in the root, with subfolder DEF. 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\> As you can see, 'ls ..\..' lists only the parent folder. This patch resolves the issue so that 'ls ..\..' lists the grandparent folder. 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(-) 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 != NULL && *Walker != CHAR_NULL ; Walker++ ){ - if (*Walker == L'\\' && *(Walker + 1) != CHAR_NULL) { - LastSlash = Walker+1; - } else if (*Walker == L':' && *(Walker + 1) != L'\\' && *(Walker + 1) != CHAR_NULL) { + if ((*Walker == L'\\' || *Walker == L':') && *(Walker + 1) != L'\\' && *(Walker + 1) != CHAR_NULL) { LastSlash = Walker+1; } } -- 2.7.4