mirror of https://github.com/acidanthera/audk.git
[Description]
Duplicate the device path prior to the access to it [Impaction] directly access the device path may cause an exception when the device path includes some unaligned device path nodes [Reference Info] In the case of ISCSI, there is a situation that the device path may consists of some unaligned device path node. it causes the unaligned exception when we access the node. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@4905 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
d63e4c2308
commit
1564e9ac2c
|
@ -1,6 +1,6 @@
|
||||||
/*++
|
/*++
|
||||||
|
|
||||||
Copyright (c) 2006 - 2007, Intel Corporation
|
Copyright (c) 2006 - 2008, Intel Corporation
|
||||||
All rights reserved. This program and the accompanying materials
|
All rights reserved. This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
which accompanies this distribution. The full text of the license may be found at
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
@ -83,7 +83,9 @@ Returns:
|
||||||
EFI_FILE_INFO *FileInfo;
|
EFI_FILE_INFO *FileInfo;
|
||||||
UINTN FileInfoSize;
|
UINTN FileInfoSize;
|
||||||
EFI_GUID *NameGuid;
|
EFI_GUID *NameGuid;
|
||||||
|
FILEPATH_DEVICE_PATH *OriginalFilePathNode;
|
||||||
|
|
||||||
|
OriginalFilePathNode = NULL;
|
||||||
*AuthenticationStatus = 0;
|
*AuthenticationStatus = 0;
|
||||||
ZeroMem (ImageFileHandle, sizeof (IMAGE_FILE_HANDLE));
|
ZeroMem (ImageFileHandle, sizeof (IMAGE_FILE_HANDLE));
|
||||||
ImageFileHandle->Signature = IMAGE_FILE_HANDLE_SIGNATURE;
|
ImageFileHandle->Signature = IMAGE_FILE_HANDLE_SIGNATURE;
|
||||||
|
@ -187,7 +189,17 @@ Returns:
|
||||||
//
|
//
|
||||||
Status = Volume->OpenVolume (Volume, &FileHandle);
|
Status = Volume->OpenVolume (Volume, &FileHandle);
|
||||||
if (!EFI_ERROR (Status)) {
|
if (!EFI_ERROR (Status)) {
|
||||||
|
//
|
||||||
|
// Duplicate the device path to avoid the access to unaligned device path node.
|
||||||
|
// Because the device path consists of one or more FILE PATH MEDIA DEVICE PATH
|
||||||
|
// nodes, It assures the fields in device path nodes are 2 byte aligned.
|
||||||
|
//
|
||||||
|
FilePathNode = (FILEPATH_DEVICE_PATH *)CoreDuplicateDevicePath((EFI_DEVICE_PATH_PROTOCOL *)(UINTN)FilePathNode);
|
||||||
|
if (FilePathNode == NULL) {
|
||||||
|
FileHandle->Close (FileHandle);
|
||||||
|
Status = EFI_OUT_OF_RESOURCES;
|
||||||
|
} else {
|
||||||
|
OriginalFilePathNode = FilePathNode;
|
||||||
//
|
//
|
||||||
// Parse each MEDIA_FILEPATH_DP node. There may be more than one, since the
|
// Parse each MEDIA_FILEPATH_DP node. There may be more than one, since the
|
||||||
// directory information and filename can be seperate. The goal is to inch
|
// directory information and filename can be seperate. The goal is to inch
|
||||||
|
@ -208,6 +220,7 @@ Returns:
|
||||||
|
|
||||||
LastHandle = FileHandle;
|
LastHandle = FileHandle;
|
||||||
FileHandle = NULL;
|
FileHandle = NULL;
|
||||||
|
|
||||||
Status = LastHandle->Open (
|
Status = LastHandle->Open (
|
||||||
LastHandle,
|
LastHandle,
|
||||||
&FileHandle,
|
&FileHandle,
|
||||||
|
@ -223,6 +236,11 @@ Returns:
|
||||||
|
|
||||||
FilePathNode = (FILEPATH_DEVICE_PATH *) NextDevicePathNode (&FilePathNode->Header);
|
FilePathNode = (FILEPATH_DEVICE_PATH *) NextDevicePathNode (&FilePathNode->Header);
|
||||||
}
|
}
|
||||||
|
//
|
||||||
|
// Free the allocated memory pool
|
||||||
|
//
|
||||||
|
CoreFreePool(OriginalFilePathNode);
|
||||||
|
}
|
||||||
|
|
||||||
if (!EFI_ERROR (Status)) {
|
if (!EFI_ERROR (Status)) {
|
||||||
//
|
//
|
||||||
|
|
Loading…
Reference in New Issue