From nobody Mon Dec 23 09:31:23 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1518061293285513.6420407039992; Wed, 7 Feb 2018 19:41:33 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 64ABC22361E59; Wed, 7 Feb 2018 19:35:47 -0800 (PST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (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 A2A1222361E4A for ; Wed, 7 Feb 2018 19:35:43 -0800 (PST) Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Feb 2018 19:41:28 -0800 Received: from ray-dev.ccr.corp.intel.com ([10.239.9.19]) by fmsmga008.fm.intel.com with ESMTP; 07 Feb 2018 19:41:27 -0800 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.93; helo=mga11.intel.com; envelope-from=ruiyu.ni@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,476,1511856000"; d="scan'208";a="16389955" From: Ruiyu Ni To: edk2-devel@lists.01.org Date: Thu, 8 Feb 2018 11:41:25 +0800 Message-Id: <20180208034125.78152-1-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.16.1.windows.1 Subject: [edk2] [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 and a NULL FileInfo. IsDirectoryEmpty() implementation in Rm.c doesn't consider this case and the deference of FileInfo->FileName causes page fault exception because FileInfo is NULL. The patch checks the return status of FileHandleFindFirstFile() to fix this issue. 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: , Cc: Jaben Carsey MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" 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(-) diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Rm.c b/ShellPkg/Li= brary/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 BS= D License which accompanies this distribution. The full text of the license may b= e 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 --=20 2.16.1.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel