From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.43; helo=mga05.intel.com; envelope-from=jaben.carsey@intel.com; receiver=edk2-devel@lists.01.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (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 D52B222361E61 for ; Thu, 8 Feb 2018 07:15:38 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Feb 2018 07:21:23 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,479,1511856000"; d="scan'208";a="16308117" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by fmsmga007.fm.intel.com with ESMTP; 08 Feb 2018 07:21:23 -0800 Received: from fmsmsx103.amr.corp.intel.com ([169.254.2.47]) by fmsmsx104.amr.corp.intel.com ([169.254.3.66]) with mapi id 14.03.0319.002; Thu, 8 Feb 2018 07:21:23 -0800 From: "Carsey, Jaben" To: "Ni, Ruiyu" , "edk2-devel@lists.01.org" Thread-Topic: [PATCH] ShellPkg/rm: fix hang when deleting an absolutely-empty directory An ordinary empty directory should contain "." and ".." entries. When an empty directory even doesn't contain "." or ".." entry, FileHandleFindFirstFile() may return error statu Thread-Index: AdOg8HiE1ev8qrzkSnia/xkTVP8mJg== Date: Thu, 8 Feb 2018 15:21:23 +0000 Message-ID: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiZTI1NzIwMWQtYWQzMC00MGMwLTkzYzUtODViMTUzNWZmYmRmIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE2LjUuOS4zIiwiVHJ1c3RlZExhYmVsSGFzaCI6Imd3YXhDK3l1bXdPbzZKcXJMMGIySXFrTmx0NHVnXC9FOTk4U2wxVURhRU9jPSJ9 x-ctpclassification: CTP_NT x-originating-ip: [10.1.200.107] MIME-Version: 1.0 Subject: Re: [PATCH] ShellPkg/rm: fix hang when deleting an absolutely-empty directory An ordinary empty directory should contain "." and ".." entries. When an empty directory even doesn't contain "." or ".." entry, FileHandleFindFirstFile() may return error statu X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Feb 2018 15:15:39 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Jaben Carsey > -----Original Message----- > From: Ni, Ruiyu > Sent: Wednesday, February 07, 2018 7:41 PM > To: edk2-devel@lists.01.org > Cc: Carsey, Jaben > Subject: [PATCH] ShellPkg/rm: fix hang when deleting an absolutely-empty > directory An ordinary empty directory should contain "." and ".." entries= . > When an empty directory even doesn't contain "." or ".." entry, > FileHandleFindFirstFile() may return error status... > Importance: High >=20 > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Ruiyu Ni > Cc: Jaben Carsey > --- > ShellPkg/Library/UefiShellLevel2CommandsLib/Rm.c | 7 ++++--- > 1 file changed, 4 insertions(+), 3 deletions(-) >=20 > diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Rm.c > b/ShellPkg/Library/UefiShellLevel2CommandsLib/Rm.c > index 618610d0f3..288e7666a8 100644 > --- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Rm.c > +++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Rm.c > @@ -2,7 +2,7 @@ > Main file for attrib shell level 2 function. >=20 > (C) Copyright 2015 Hewlett-Packard Development Company, L.P.
> - Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.
> + Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.
> This program and the accompanying materials > are licensed and made available under the terms and conditions of the = BSD > License > which accompanies this distribution. The full text of the license may= be > found at > @@ -33,6 +33,7 @@ IsDirectoryEmpty ( > IN EFI_HANDLE FileHandle > ) > { > + EFI_STATUS Status; > EFI_FILE_INFO *FileInfo; > BOOLEAN NoFile; > BOOLEAN RetVal; > @@ -41,8 +42,8 @@ IsDirectoryEmpty ( > NoFile =3D FALSE; > FileInfo =3D NULL; >=20 > - for (FileHandleFindFirstFile(FileHandle, &FileInfo) > - ; !NoFile > + for (Status =3D FileHandleFindFirstFile(FileHandle, &FileInfo) > + ; !NoFile && !EFI_ERROR (Status) > ; FileHandleFindNextFile(FileHandle, FileInfo, &NoFile) > ){ > if (StrStr(FileInfo->FileName, L".") !=3D FileInfo->FileName > -- > 2.16.1.windows.1