From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35]) by mx.groups.io with SMTP id smtpd.web12.5915.1610435336334054204 for ; Mon, 11 Jan 2021 23:08:57 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: huawei.com, ip: 45.249.212.35, mailfrom: xiewenyi2@huawei.com) Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4DFM9271Yvz7TB0 for ; Tue, 12 Jan 2021 15:07:50 +0800 (CST) Received: from HGH1000039998.huawei.com (10.184.68.188) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.498.0; Tue, 12 Jan 2021 15:08:45 +0800 From: "wenyi,xie" To: , , , , CC: , Subject: [PATCH EDK2 v1 1/1] MdeModulePkg/FileExplorerLib: Add return value check Date: Tue, 12 Jan 2021 15:06:38 +0800 Message-ID: <1610435198-12504-2-git-send-email-xiewenyi2@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1610435198-12504-1-git-send-email-xiewenyi2@huawei.com> References: <1610435198-12504-1-git-send-email-xiewenyi2@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.184.68.188] X-CFilter-Loop: Reflected Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3113 According to FAT specification, the length of file path should not larger than 260. When the length exceed 260, function FatLocateOFile will return EFI_INVALID_PARAMETER and the parameter FileHandle will be NULL. Then on the top-level function=EF=BC=8Can exception happens when the NULL pointer is passed and be used. So adding return value check after calling LibGetFileHandleFromMenu, if return value is not success, stop calling LibFindFiles. Cc: Jian J Wang Cc: Hao A Wu Cc: Dandan Bi Cc: Eric Dong Signed-off-by: Wenyi Xie --- MdeModulePkg/Library/FileExplorerLib/FileExplorer.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/MdeModulePkg/Library/FileExplorerLib/FileExplorer.c b/MdeMod= ulePkg/Library/FileExplorerLib/FileExplorer.c index 13a214b06af9..03630a29bc3b 100644 --- a/MdeModulePkg/Library/FileExplorerLib/FileExplorer.c +++ b/MdeModulePkg/Library/FileExplorerLib/FileExplorer.c @@ -1408,12 +1408,14 @@ LibUpdateFileExplorer ( if (NewFileContext->IsDir) { RemoveEntryList (&NewMenuEntry->Link); LibFreeMenu (gFileExplorerPrivate.FsOptionMenu); - LibGetFileHandleFromMenu (NewMenuEntry, &FileHandle); - Status =3D LibFindFiles (FileHandle, NewFileContext->FileName, NewFi= leContext->DeviceHandle); + Status =3D LibGetFileHandleFromMenu (NewMenuEntry, &FileHandle); if (!EFI_ERROR (Status)) { - LibUpdateFileExplorePage (); - } else { - LibFreeMenu (gFileExplorerPrivate.FsOptionMenu); + Status =3D LibFindFiles (FileHandle, NewFileContext->FileName, New= FileContext->DeviceHandle); + if (!EFI_ERROR (Status)) { + LibUpdateFileExplorePage (); + } else { + LibFreeMenu (gFileExplorerPrivate.FsOptionMenu); + } } LibDestroyMenuEntry (NewMenuEntry); } --=20 2.20.1.windows.1