This commit adds ASSERTs to address false positive reports of NULL pointer dereference issues raised from static analysis with regard to function ReadDirectoryEntry().
Cc: Ruiyu Ni <[email protected]> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Hao Wu <[email protected]> Reviewed-by: Paulo Alcantara <[email protected]> Reviewed-by: Star Zeng <[email protected]> --- MdeModulePkg/Universal/Disk/UdfDxe/File.c | 9 +++++++++ MdeModulePkg/Universal/Disk/UdfDxe/FileSystemOperations.c | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/MdeModulePkg/Universal/Disk/UdfDxe/File.c b/MdeModulePkg/Universal/Disk/UdfDxe/File.c index 6f07bf2066..2249f4ea0e 100644 --- a/MdeModulePkg/Universal/Disk/UdfDxe/File.c +++ b/MdeModulePkg/Universal/Disk/UdfDxe/File.c @@ -408,6 +408,15 @@ UdfRead ( goto Done; } + // + // After calling function ReadDirectoryEntry(), if 'NewFileIdentifierDesc' + // is NULL, then the 'Status' must be EFI_OUT_OF_RESOURCES. Hence, if the + // code reaches here, 'NewFileIdentifierDesc' must be not NULL. + // + // The ASSERT here is for addressing a false positive NULL pointer + // dereference issue raised from static analysis. + // + ASSERT (NewFileIdentifierDesc != NULL); if (!IS_FID_PARENT_FILE (NewFileIdentifierDesc)) { break; diff --git a/MdeModulePkg/Universal/Disk/UdfDxe/FileSystemOperations.c b/MdeModulePkg/Universal/Disk/UdfDxe/FileSystemOperations.c index 638f31bd82..8b58cc9eb1 100644 --- a/MdeModulePkg/Universal/Disk/UdfDxe/FileSystemOperations.c +++ b/MdeModulePkg/Universal/Disk/UdfDxe/FileSystemOperations.c @@ -1404,6 +1404,15 @@ InternalFindFile ( break; } + // + // After calling function ReadDirectoryEntry(), if 'FileIdentifierDesc' is + // NULL, then the 'Status' must be EFI_OUT_OF_RESOURCES. Hence, if the code + // reaches here, 'FileIdentifierDesc' must be not NULL. + // + // The ASSERT here is for addressing a false positive NULL pointer + // dereference issue raised from static analysis. + // + ASSERT (FileIdentifierDesc != NULL); if (FileIdentifierDesc->FileCharacteristics & PARENT_FILE) { // -- 2.12.0.windows.1 _______________________________________________ edk2-devel mailing list [email protected] https://lists.01.org/mailman/listinfo/edk2-devel

