public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [patch] MdeModulePkg/FvSimpleFileSystem: fix assertions when FV is empty
@ 2016-08-02  8:09 Feng Tian
  2016-08-02 12:42 ` Zhang, Chao B
  0 siblings, 1 reply; 2+ messages in thread
From: Feng Tian @ 2016-08-02  8:09 UTC (permalink / raw)
  To: chao.b.zhang; +Cc: edk2-devel

The original code will assert when dealing with those empty FVs.
The fix is used to solve this bug.

Cc: Chao Zhang <chao.b.zhang@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Feng Tian <feng.tian@intel.com>
---
 .../Universal/FvSimpleFileSystemDxe/FvSimpleFileSystem.c         | 9 +++++++--
 .../FvSimpleFileSystemDxe/FvSimpleFileSystemEntryPoint.c         | 6 +++++-
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/MdeModulePkg/Universal/FvSimpleFileSystemDxe/FvSimpleFileSystem.c b/MdeModulePkg/Universal/FvSimpleFileSystemDxe/FvSimpleFileSystem.c
index c6137ac..b81110f 100644
--- a/MdeModulePkg/Universal/FvSimpleFileSystemDxe/FvSimpleFileSystem.c
+++ b/MdeModulePkg/Universal/FvSimpleFileSystemDxe/FvSimpleFileSystem.c
@@ -526,7 +526,10 @@ FvSimpleFileSystemOpen (
     InitializeListHead (&NewFile->Link);
     InsertHeadList (&Instance->FileHead, &NewFile->Link);
 
-    NewFile->DirReadNext = FVFS_GET_FIRST_FILE_INFO (Instance);
+    NewFile->DirReadNext = NULL;
+    if (!IsListEmpty (&Instance->FileInfoHead)) {
+      NewFile->DirReadNext = FVFS_GET_FIRST_FILE_INFO (Instance);
+    }
 
     *NewHandle = &NewFile->FileProtocol;
     return EFI_SUCCESS;
@@ -821,7 +824,9 @@ FvSimpleFileSystemSetPosition (
     //
     // Reset directory position to first entry
     //
-    File->DirReadNext = FVFS_GET_FIRST_FILE_INFO (Instance);
+    if (File->DirReadNext) {
+      File->DirReadNext = FVFS_GET_FIRST_FILE_INFO (Instance); 
+    }
   } else if (Position == 0xFFFFFFFFFFFFFFFFull) {
     File->Position = File->FvFileInfo->FileInfo.FileSize;
   } else {
diff --git a/MdeModulePkg/Universal/FvSimpleFileSystemDxe/FvSimpleFileSystemEntryPoint.c b/MdeModulePkg/Universal/FvSimpleFileSystemDxe/FvSimpleFileSystemEntryPoint.c
index 7167fb9..4e6089b 100644
--- a/MdeModulePkg/Universal/FvSimpleFileSystemDxe/FvSimpleFileSystemEntryPoint.c
+++ b/MdeModulePkg/Universal/FvSimpleFileSystemDxe/FvSimpleFileSystemEntryPoint.c
@@ -223,7 +223,11 @@ FvSimpleFileSystemOpenVolume (
     }
   }
 
-  Instance->Root->DirReadNext = FVFS_GET_FIRST_FILE_INFO (Instance);
+  Instance->Root->DirReadNext = NULL;
+  if (!IsListEmpty (&Instance->FileInfoHead)) {
+    Instance->Root->DirReadNext = FVFS_GET_FIRST_FILE_INFO (Instance);
+  }
+
   *RootFile = &Instance->Root->FileProtocol;
   return Status;
 }
-- 
2.7.1.windows.2



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-08-02 12:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-02  8:09 [patch] MdeModulePkg/FvSimpleFileSystem: fix assertions when FV is empty Feng Tian
2016-08-02 12:42 ` Zhang, Chao B

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox