]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/FileExplorerLib: Add return value check
authorwenyi,xie via groups.io <xiewenyi2=huawei.com@groups.io>
Tue, 12 Jan 2021 07:06:38 +0000 (15:06 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Fri, 15 Jan 2021 01:08:45 +0000 (01:08 +0000)
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>
MdeModulePkg/Library/FileExplorerLib/FileExplorer.c

index 13a214b06af9fdc262fababe32abd614a0c4ed6c..03630a29bc3b780765c505b394acd1c877e9380b 100644 (file)
@@ -1408,12 +1408,14 @@ LibUpdateFileExplorer (
   if (NewFileContext->IsDir) {\r
     RemoveEntryList (&NewMenuEntry->Link);\r
     LibFreeMenu (gFileExplorerPrivate.FsOptionMenu);\r
-    LibGetFileHandleFromMenu (NewMenuEntry, &FileHandle);\r
-    Status = LibFindFiles (FileHandle, NewFileContext->FileName, NewFileContext->DeviceHandle);\r
+    Status = LibGetFileHandleFromMenu (NewMenuEntry, &FileHandle);\r
     if (!EFI_ERROR (Status)) {\r
-      LibUpdateFileExplorePage ();\r
-    } else {\r
-      LibFreeMenu (gFileExplorerPrivate.FsOptionMenu);\r
+      Status = LibFindFiles (FileHandle, NewFileContext->FileName, NewFileContext->DeviceHandle);\r
+      if (!EFI_ERROR (Status)) {\r
+        LibUpdateFileExplorePage ();\r
+      } else {\r
+        LibFreeMenu (gFileExplorerPrivate.FsOptionMenu);\r
+      }\r
     }\r
     LibDestroyMenuEntry (NewMenuEntry);\r
   }\r