]> 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 f08577cf280d5820c80d513a7d352cfbdc859a73..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
@@ -808,7 +808,7 @@ CreateChildNode (
         // Make sure we initialize the new stream with the correct \r
         // authentication status for both aggregate and local status fields.\r
         //\r
-        if ((GuidedHeader->Attributes & EFI_GUIDED_SECTION_AUTH_STATUS_VALID) != 0) {\r
+        if ((GuidedHeader->Attributes & EFI_GUIDED_SECTION_AUTH_STATUS_VALID) == EFI_GUIDED_SECTION_AUTH_STATUS_VALID) {\r
           //\r
           // OR in the parent stream's aggregate status.\r
           //\r
@@ -837,7 +837,7 @@ CreateChildNode (
         //\r
         // There's no GUIDed section extraction protocol available.\r
         //\r
-        if ((GuidedHeader->Attributes & EFI_GUIDED_SECTION_PROCESSING_REQUIRED) != 0) {\r
+        if ((GuidedHeader->Attributes & EFI_GUIDED_SECTION_PROCESSING_REQUIRED) == EFI_GUIDED_SECTION_PROCESSING_REQUIRED) {\r
           //\r
           // If the section REQUIRES an extraction protocol, then we're toast\r
           //\r
@@ -849,7 +849,7 @@ CreateChildNode (
         // Figure out the proper authentication status\r
         //\r
         AuthenticationStatus = Stream->AuthenticationStatus;\r
-        if (GuidedHeader->Attributes & EFI_GUIDED_SECTION_AUTH_STATUS_VALID) {\r
+        if ((GuidedHeader->Attributes & EFI_GUIDED_SECTION_AUTH_STATUS_VALID) == EFI_GUIDED_SECTION_AUTH_STATUS_VALID) {\r
           //\r
           //  The local status of the new stream is contained in \r
           //  AuthenticaionStatus.  This value needs to be ORed into the\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