From: Hao Wu <hao.a.wu@intel.com>
To: edk2-devel@lists.01.org
Cc: Hao Wu <hao.a.wu@intel.com>, Ruiyu Ni <ruiyu.ni@intel.com>
Subject: [PATCH v2 2/6] MdeModulePkg/UdfDxe: ASSERT for false positives of NULL ptr deref
Date: Tue, 16 Oct 2018 16:14:38 +0800 [thread overview]
Message-ID: <20181016081442.24236-3-hao.a.wu@intel.com> (raw)
In-Reply-To: <20181016081442.24236-1-hao.a.wu@intel.com>
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 <ruiyu.ni@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Paulo Alcantara <palcantara@suse.de>
Reviewed-by: Star Zeng <star.zeng@intel.com>
---
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
next prev parent reply other threads:[~2018-10-16 8:14 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-16 8:14 [PATCH v2 0/6] Code refinements in UdfDxe Hao Wu
2018-10-16 8:14 ` [PATCH v2 1/6] MdeModulePkg/UdfDxe: Use error handling for memory allocation failure Hao Wu
2018-10-16 8:14 ` Hao Wu [this message]
2018-10-16 8:14 ` [PATCH v2 3/6] MdeModulePkg/UdfDxe: Use error handling when fail to return LSN Hao Wu
2018-10-16 8:14 ` [PATCH v2 4/6] MdeModulePkg/UdfDxe: Use debug msg instead of ASSERT in UdfOpen() Hao Wu
2018-10-16 8:14 ` [PATCH v2 5/6] MdeModulePkg/UdfDxe: Handle dead codes in File.c Hao Wu
2018-10-16 8:14 ` [PATCH v2 6/6] MdeModulePkg/UdfDxe: Handle dead codes in FileSystemOperations.c Hao Wu
2018-10-17 2:48 ` [PATCH v2 0/6] Code refinements in UdfDxe Zeng, Star
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181016081442.24236-3-hao.a.wu@intel.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox