From 5fb22f5920039393f74030c74c216517a131dbe0 Mon Sep 17 00:00:00 2001 From: Hao Wu Date: Tue, 9 Oct 2018 11:03:27 +0800 Subject: [PATCH] MdeModulePkg/UdfDxe: ASSERT for false positives of NULL ptr deref 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 Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Hao Wu Reviewed-by: Paulo Alcantara Reviewed-by: Star Zeng --- MdeModulePkg/Universal/Disk/UdfDxe/File.c | 9 +++++++++ .../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.39.2