Enhance the error handling.
Signed-off-by: ydong10 Reviewed-by: lzeng14 git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13094 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
@ -27,7 +27,7 @@
|
|||||||
3) A support protocol is not found, and the data is not available to be read
|
3) A support protocol is not found, and the data is not available to be read
|
||||||
without it. This results in EFI_PROTOCOL_ERROR.
|
without it. This results in EFI_PROTOCOL_ERROR.
|
||||||
|
|
||||||
Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
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
|
||||||
@ -667,8 +667,8 @@ CreateGuidedExtractionRpnEvent (
|
|||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
CreateChildNode (
|
CreateChildNode (
|
||||||
IN FRAMEWORK_SECTION_STREAM_NODE *Stream,
|
IN FRAMEWORK_SECTION_STREAM_NODE *Stream,
|
||||||
IN UINT32 ChildOffset,
|
IN UINT32 ChildOffset,
|
||||||
OUT FRAMEWORK_SECTION_CHILD_NODE **ChildNode
|
OUT FRAMEWORK_SECTION_CHILD_NODE **ChildNode
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
@ -723,8 +723,11 @@ CreateChildNode (
|
|||||||
//
|
//
|
||||||
// Get the CompressionSectionHeader
|
// Get the CompressionSectionHeader
|
||||||
//
|
//
|
||||||
ASSERT (Node->Size >= sizeof (EFI_COMPRESSION_SECTION));
|
if (Node->Size < sizeof (EFI_COMPRESSION_SECTION)) {
|
||||||
|
CoreFreePool (Node);
|
||||||
|
return EFI_NOT_FOUND;
|
||||||
|
}
|
||||||
|
|
||||||
CompressionHeader = (EFI_COMPRESSION_SECTION *) SectionHeader;
|
CompressionHeader = (EFI_COMPRESSION_SECTION *) SectionHeader;
|
||||||
|
|
||||||
if (IS_SECTION2 (CompressionHeader)) {
|
if (IS_SECTION2 (CompressionHeader)) {
|
||||||
@ -774,8 +777,14 @@ CreateChildNode (
|
|||||||
(UINT32 *)&NewStreamBufferSize,
|
(UINT32 *)&NewStreamBufferSize,
|
||||||
&ScratchSize
|
&ScratchSize
|
||||||
);
|
);
|
||||||
ASSERT_EFI_ERROR (Status);
|
if (EFI_ERROR (Status) || (NewStreamBufferSize != UncompressedLength)) {
|
||||||
ASSERT (NewStreamBufferSize == UncompressedLength);
|
CoreFreePool (Node);
|
||||||
|
CoreFreePool (NewStreamBuffer);
|
||||||
|
if (!EFI_ERROR (Status)) {
|
||||||
|
Status = EFI_BAD_BUFFER_SIZE;
|
||||||
|
}
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
ScratchBuffer = AllocatePool (ScratchSize);
|
ScratchBuffer = AllocatePool (ScratchSize);
|
||||||
if (ScratchBuffer == NULL) {
|
if (ScratchBuffer == NULL) {
|
||||||
@ -793,8 +802,12 @@ CreateChildNode (
|
|||||||
ScratchBuffer,
|
ScratchBuffer,
|
||||||
ScratchSize
|
ScratchSize
|
||||||
);
|
);
|
||||||
ASSERT_EFI_ERROR (Status);
|
FreePool (ScratchBuffer);
|
||||||
FreePool (ScratchBuffer);
|
if (EFI_ERROR (Status)) {
|
||||||
|
CoreFreePool (Node);
|
||||||
|
CoreFreePool (NewStreamBuffer);
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
NewStreamBuffer = NULL;
|
NewStreamBuffer = NULL;
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
3) A support protocol is not found, and the data is not available to be read
|
3) A support protocol is not found, and the data is not available to be read
|
||||||
without it. This results in EFI_PROTOCOL_ERROR.
|
without it. This results in EFI_PROTOCOL_ERROR.
|
||||||
|
|
||||||
Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
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
|
||||||
@ -619,7 +619,7 @@ EFI_STATUS
|
|||||||
CreateChildNode (
|
CreateChildNode (
|
||||||
IN CORE_SECTION_STREAM_NODE *Stream,
|
IN CORE_SECTION_STREAM_NODE *Stream,
|
||||||
IN UINT32 ChildOffset,
|
IN UINT32 ChildOffset,
|
||||||
OUT CORE_SECTION_CHILD_NODE **ChildNode
|
OUT CORE_SECTION_CHILD_NODE **ChildNode
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
@ -674,7 +674,10 @@ CreateChildNode (
|
|||||||
//
|
//
|
||||||
// Get the CompressionSectionHeader
|
// Get the CompressionSectionHeader
|
||||||
//
|
//
|
||||||
ASSERT (Node->Size >= sizeof (EFI_COMPRESSION_SECTION));
|
if (Node->Size < sizeof (EFI_COMPRESSION_SECTION)) {
|
||||||
|
CoreFreePool (Node);
|
||||||
|
return EFI_NOT_FOUND;
|
||||||
|
}
|
||||||
|
|
||||||
CompressionHeader = (EFI_COMPRESSION_SECTION *) SectionHeader;
|
CompressionHeader = (EFI_COMPRESSION_SECTION *) SectionHeader;
|
||||||
|
|
||||||
@ -725,8 +728,14 @@ CreateChildNode (
|
|||||||
(UINT32 *)&NewStreamBufferSize,
|
(UINT32 *)&NewStreamBufferSize,
|
||||||
&ScratchSize
|
&ScratchSize
|
||||||
);
|
);
|
||||||
ASSERT_EFI_ERROR (Status);
|
if (EFI_ERROR (Status) || (NewStreamBufferSize != UncompressedLength)) {
|
||||||
ASSERT (NewStreamBufferSize == UncompressedLength);
|
CoreFreePool (Node);
|
||||||
|
CoreFreePool (NewStreamBuffer);
|
||||||
|
if (!EFI_ERROR (Status)) {
|
||||||
|
Status = EFI_BAD_BUFFER_SIZE;
|
||||||
|
}
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
ScratchBuffer = AllocatePool (ScratchSize);
|
ScratchBuffer = AllocatePool (ScratchSize);
|
||||||
if (ScratchBuffer == NULL) {
|
if (ScratchBuffer == NULL) {
|
||||||
@ -744,8 +753,12 @@ CreateChildNode (
|
|||||||
ScratchBuffer,
|
ScratchBuffer,
|
||||||
ScratchSize
|
ScratchSize
|
||||||
);
|
);
|
||||||
ASSERT_EFI_ERROR (Status);
|
|
||||||
CoreFreePool (ScratchBuffer);
|
CoreFreePool (ScratchBuffer);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
CoreFreePool (Node);
|
||||||
|
CoreFreePool (NewStreamBuffer);
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
NewStreamBuffer = NULL;
|
NewStreamBuffer = NULL;
|
||||||
|
Reference in New Issue
Block a user