[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:
eric_tian 2008-03-19 02:05:57 +00:00
parent d63e4c2308
commit 1564e9ac2c
1 changed files with 49 additions and 31 deletions

View File

@ -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
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
@ -83,7 +83,9 @@ Returns:
EFI_FILE_INFO *FileInfo;
UINTN FileInfoSize;
EFI_GUID *NameGuid;
FILEPATH_DEVICE_PATH *OriginalFilePathNode;
OriginalFilePathNode = NULL;
*AuthenticationStatus = 0;
ZeroMem (ImageFileHandle, sizeof (IMAGE_FILE_HANDLE));
ImageFileHandle->Signature = IMAGE_FILE_HANDLE_SIGNATURE;
@ -187,7 +189,17 @@ Returns:
//
Status = Volume->OpenVolume (Volume, &FileHandle);
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
// directory information and filename can be seperate. The goal is to inch
@ -208,6 +220,7 @@ Returns:
LastHandle = FileHandle;
FileHandle = NULL;
Status = LastHandle->Open (
LastHandle,
&FileHandle,
@ -223,6 +236,11 @@ Returns:
FilePathNode = (FILEPATH_DEVICE_PATH *) NextDevicePathNode (&FilePathNode->Header);
}
//
// Free the allocated memory pool
//
CoreFreePool(OriginalFilePathNode);
}
if (!EFI_ERROR (Status)) {
//