]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/UdfDxe: Fix NULL pointer dereference
authorPaulo Alcantara <pcacjr@zytor.com>
Tue, 12 Sep 2017 01:30:23 +0000 (09:30 +0800)
committerStar Zeng <star.zeng@intel.com>
Fri, 15 Sep 2017 01:38:05 +0000 (09:38 +0800)
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=704

For root directory, the FID (File Identifier Descriptor) pointer is
accessible through PRIVATE_UDF_FILE_DATA.Root, whereas non-root
directory and regular files, their FIDs are accessible through
PRIVATE_UDF_FILE_DATA.File.

In UdfSetPosition(), the FID was retrieved through
PRIVATE_UDF_FILE_DATA.File, hence when calling it with a root directory,
PRIVATE_UDF_FILE_DATA.File.FileIdentifierDescriptor would be NULL and
then dereferenced.

This patch fixes the NULL pointer dereference by calling _FILE() to
transparently return the correct UDF_FILE_INFO * which points to a valid
FID descriptor of a specific file.

Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Steven Shi <steven.shi@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Reported-by: Steven Shi <steven.shi@intel.com>
Signed-off-by: Paulo Alcantara <pcacjr@zytor.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
MdeModulePkg/Universal/Disk/UdfDxe/File.c

index e7159ff861f7a0359336b44a8b8c261eb0f8df82..01361141bbc3e707a0c9110c6123c8b18939a19a 100644 (file)
@@ -692,7 +692,8 @@ UdfSetPosition (
 \r
   PrivFileData = PRIVATE_UDF_FILE_DATA_FROM_THIS (This);\r
 \r
-  FileIdentifierDesc = PrivFileData->File.FileIdentifierDesc;\r
+  FileIdentifierDesc = _FILE (PrivFileData)->FileIdentifierDesc;\r
+  ASSERT (FileIdentifierDesc != NULL);\r
   if (IS_FID_DIRECTORY_FILE (FileIdentifierDesc)) {\r
     //\r
     // If the file handle is a directory, the _only_ position that may be set is\r