summaryrefslogtreecommitdiffstats
path: root/MdeModulePkg
diff options
context:
space:
mode:
authorwenyi,xie via groups.io <xiewenyi2=huawei.com@groups.io>2021-01-12 15:06:38 +0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2021-01-15 01:08:45 +0000
commit014b9850f2a33ae402b87c46268f4d98395d5d59 (patch)
tree5339c63cf5d017117f3b0d87aa0415475f9d03dd /MdeModulePkg
parent40c4cd54213b78ef0daee2f4b186150d7ef63bb4 (diff)
downloadedk2-014b9850f2a33ae402b87c46268f4d98395d5d59.tar.gz
edk2-014b9850f2a33ae402b87c46268f4d98395d5d59.tar.bz2
edk2-014b9850f2a33ae402b87c46268f4d98395d5d59.zip
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>
Diffstat (limited to 'MdeModulePkg')
-rw-r--r--MdeModulePkg/Library/FileExplorerLib/FileExplorer.c12
1 files changed, 7 insertions, 5 deletions
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);
}