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 <jian.j.wang@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Dandan Bi <dandan.bi@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Signed-off-by: Wenyi Xie <xiewenyi2@huawei.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Dandan Bi <dandan.bi@intel.com>
This commit is contained in:
wenyi,xie via groups.io 2021-01-12 15:06:38 +08:00 committed by mergify[bot]
parent 40c4cd5421
commit 014b9850f2
1 changed files with 7 additions and 5 deletions

View File

@ -1408,13 +1408,15 @@ LibUpdateFileExplorer (
if (NewFileContext->IsDir) {
RemoveEntryList (&NewMenuEntry->Link);
LibFreeMenu (gFileExplorerPrivate.FsOptionMenu);
LibGetFileHandleFromMenu (NewMenuEntry, &FileHandle);
Status = LibGetFileHandleFromMenu (NewMenuEntry, &FileHandle);
if (!EFI_ERROR (Status)) {
Status = LibFindFiles (FileHandle, NewFileContext->FileName, NewFileContext->DeviceHandle);
if (!EFI_ERROR (Status)) {
LibUpdateFileExplorePage ();
} else {
LibFreeMenu (gFileExplorerPrivate.FsOptionMenu);
}
}
LibDestroyMenuEntry (NewMenuEntry);
}