In the ReadFile() function, if "RecordingFlags" is INLINE_DATA, then we
cover the following values of "ReadFileInfo->Flags":

- READ_FILE_GET_FILESIZE
- READ_FILE_ALLOCATE_AND_READ
- READ_FILE_SEEK_AND_READ

We don't do anything (just proceed to the end of the function) if
"ReadFileInfo->Flags" is anything else.

In reality the above three values cover the domain of the
UDF_READ_FILE_FLAGS enum type fully, and "ReadFileInfo->Flags" is only
ever set internally to UdfDxe. Therefore any other flag value would be a
bug in UdfDxe.

ASSERT() specifically that "ReadFileInfo->Flags" has been set correctly,
so that the reader is not left wondering what happens if none of the enum
constants match.

Cc: Ard Biesheuvel <[email protected]>
Cc: Eric Dong <[email protected]>
Cc: Paulo Alcantara <[email protected]>
Cc: Ruiyu Ni <[email protected]>
Cc: Star Zeng <[email protected]>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Laszlo Ersek <[email protected]>
---
 MdeModulePkg/Universal/Disk/UdfDxe/FileSystemOperations.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/MdeModulePkg/Universal/Disk/UdfDxe/FileSystemOperations.c 
b/MdeModulePkg/Universal/Disk/UdfDxe/FileSystemOperations.c
index 7d7f722188c5..a2ca65e5dfe8 100644
--- a/MdeModulePkg/Universal/Disk/UdfDxe/FileSystemOperations.c
+++ b/MdeModulePkg/Universal/Disk/UdfDxe/FileSystemOperations.c
@@ -953,10 +953,13 @@ ReadFile (
         (VOID *)((UINT8 *)Data + ReadFileInfo->FilePosition),
         ReadFileInfo->FileDataSize
         );
 
       ReadFileInfo->FilePosition += ReadFileInfo->FileDataSize;
+    } else {
+      ASSERT (FALSE);
+      return EFI_INVALID_PARAMETER;
     }
 
     break;
   case LONG_ADS_SEQUENCE:
   case SHORT_ADS_SEQUENCE:
-- 
2.14.1.3.gb7cf6e02401b


_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to