From 014b9850f2a33ae402b87c46268f4d98395d5d59 Mon Sep 17 00:00:00 2001 From: "wenyi,xie via groups.io" Date: Tue, 12 Jan 2021 15:06:38 +0800 Subject: MdeModulePkg/FileExplorerLib: Add return value check REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3113 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?an 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 Reviewed-by: Liming Gao Reviewed-by: Dandan Bi --- MdeModulePkg/Library/FileExplorerLib/FileExplorer.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'MdeModulePkg') diff --git a/MdeModulePkg/Library/FileExplorerLib/FileExplorer.c b/MdeModulePkg/Library/FileExplorerLib/FileExplorer.c index 13a214b06a..03630a29bc 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 = LibFindFiles (FileHandle, NewFileContext->FileName, NewFileContext->DeviceHandle); + Status = LibGetFileHandleFromMenu (NewMenuEntry, &FileHandle); if (!EFI_ERROR (Status)) { - LibUpdateFileExplorePage (); - } else { - LibFreeMenu (gFileExplorerPrivate.FsOptionMenu); + Status = LibFindFiles (FileHandle, NewFileContext->FileName, NewFileContext->DeviceHandle); + if (!EFI_ERROR (Status)) { + LibUpdateFileExplorePage (); + } else { + LibFreeMenu (gFileExplorerPrivate.FsOptionMenu); + } } LibDestroyMenuEntry (NewMenuEntry); } -- cgit v1.2.3