]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelFrameworkModulePkg/Universal/SectionExtractionDxe/SectionExtraction.c
Fix a bug that FV->ReadSection cannot get the EFI_SECTION_GUID_DEFINED type section...
[mirror_edk2.git] / IntelFrameworkModulePkg / Universal / SectionExtractionDxe / SectionExtraction.c
index 10a992a801c86604a7a7d053c2e6e2415eb700e3..5d3bb50da7163a50f477ccae4527d8180cf6f573 100644 (file)
@@ -27,7 +27,7 @@
   3) A support protocol is not found, and the data is not available to be read\r
      without it.  This results in EFI_PROTOCOL_ERROR.\r
 \r
-Copyright (c) 2006 - 2009, Intel Corporation. <BR>\r
+Copyright (c) 2006 - 2010, Intel Corporation. <BR>\r
 All rights reserved. This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -327,7 +327,7 @@ OpenSectionStreamEx (
   )\r
 {\r
   FRAMEWORK_SECTION_STREAM_NODE    *NewStream;\r
-  EFI_TPL                     OldTpl;\r
+  EFI_TPL                          OldTpl;\r
   \r
   //\r
   // Allocate a new stream\r
@@ -446,8 +446,8 @@ BOOLEAN
 ChildIsType (\r
   IN FRAMEWORK_SECTION_STREAM_NODE *Stream,\r
   IN FRAMEWORK_SECTION_CHILD_NODE  *Child,\r
-  IN EFI_SECTION_TYPE         SearchType,\r
-  IN EFI_GUID                 *SectionDefinitionGuid\r
+  IN EFI_SECTION_TYPE              SearchType,\r
+  IN EFI_GUID                      *SectionDefinitionGuid\r
   )\r
 {\r
   EFI_GUID_DEFINED_SECTION    *GuidedSection;\r
@@ -458,7 +458,7 @@ ChildIsType (
   if (Child->Type != SearchType) {\r
     return FALSE;\r
   }\r
-  if (SearchType != EFI_SECTION_GUID_DEFINED) {\r
+  if ((SearchType != EFI_SECTION_GUID_DEFINED) || (SectionDefinitionGuid == NULL)) {\r
     return TRUE;\r
   }\r
   GuidedSection = (EFI_GUID_DEFINED_SECTION * )(Stream->StreamBuffer + Child->OffsetInStream);\r
@@ -1000,6 +1000,7 @@ FindChildNode (
       }\r
     }\r
     \r
+    ASSERT (CurrentChildNode != NULL);\r
     if (CurrentChildNode->EncapsulatedStreamHandle != NULL_STREAM_HANDLE) {\r
       //\r
       // If the current node is an encapsulating node, recurse into it...\r
@@ -1154,11 +1155,11 @@ GetSection (
   OUT UINT32                                            *AuthenticationStatus\r
   )\r
 {\r
-  FRAMEWORK_SECTION_STREAM_NODE                              *StreamNode;\r
+  FRAMEWORK_SECTION_STREAM_NODE                         *StreamNode;\r
   EFI_TPL                                               OldTpl;\r
   EFI_STATUS                                            Status;\r
-  FRAMEWORK_SECTION_CHILD_NODE                               *ChildNode;\r
-  FRAMEWORK_SECTION_STREAM_NODE                              *ChildStreamNode;\r
+  FRAMEWORK_SECTION_CHILD_NODE                          *ChildNode;\r
+  FRAMEWORK_SECTION_STREAM_NODE                         *ChildStreamNode;\r
   UINTN                                                 CopySize;\r
   UINT32                                                ExtractedAuthenticationStatus;\r
   UINTN                                                 Instance;\r
@@ -1204,6 +1205,8 @@ GetSection (
     if (EFI_ERROR (Status)) {\r
       goto GetSection_Done;\r
     }\r
+    ASSERT (ChildNode != NULL);\r
+    ASSERT (ChildStreamNode != NULL);\r
     CopySize = ChildNode->Size - sizeof (EFI_COMMON_SECTION_HEADER);\r
     CopyBuffer = ChildStreamNode->StreamBuffer + ChildNode->OffsetInStream + sizeof (EFI_COMMON_SECTION_HEADER);\r
     *AuthenticationStatus = ExtractedAuthenticationStatus;\r