audk/MdeModulePkg/Universal/Disk
Hao Wu 7a96634889 MdeModulePkg/UdfDxe: Avoid possible loss track of allocated buffer
In function FindFileEntry():

Instead of using the function parameter 'FileEntry', use a local
variable to store the buffer allocated for disk read operation.

For the below calling stack:
UdfOpenVolume() -> FindRootDirectory() -> FindFileEntry()

In FindFileEntry(), the call to 'DiskIo->ReadDisk()' is possible (e.g.
media change for a CD/DVD ROM device) to trigger a re-install of the
BlockIO(2) protocol which will further lead to a call of the BindingStop()
& BingdingStart() of the UdfDxe driver.

Meanwhile, for the above listed calling stack, the '**FileEntry'
parameter passed into FindFileEntry() is '&PrivFsData->Root'. 'PrivFsData'
is a driver-managed private data, it will be freed in BindingStop() and
re-allocate in BingdingStart().

In such case, if '*FileEntry' is used to store the allocated buffer, the
information will be lost if 'DiskIo->ReadDisk()' triggers a re-install of
the BlockIO(2) protocol. The subsequent call of the FreePool API:

FreePool (*FileEntry);

will cause issues.

This commit uses a local variable to store the allocated buffer.

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Paulo Alcantara <pcacjr@zytor.com>
2017-11-20 08:54:22 +08:00
..
CdExpressPei MdeModulePkg/CdExpressPei: Use PcdRecoveryFileName PCD. 2016-10-12 09:15:23 +08:00
DiskIoDxe MdeModulePkg DiskIoDxe: Media status check not be done at DiskIo level 2016-03-29 13:39:13 +08:00
PartitionDxe MdeModulePkg/PartitionDxe: Merge the discovery of ElTorito into UDF 2017-11-20 08:54:17 +08:00
RamDiskDxe MdeModulePkg/RamDiskDxe: fix C string literal catenation in info messages 2017-03-20 11:06:36 +01:00
UdfDxe MdeModulePkg/UdfDxe: Avoid possible loss track of allocated buffer 2017-11-20 08:54:22 +08:00
UnicodeCollation/EnglishDxe MdeModulePkg: Convert all .uni files to utf-8 2015-12-15 04:56:23 +00:00