]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/Dxe/SectionExtraction/CoreSectionExtraction.c
Fix a bug that FV->ReadSection cannot get the EFI_SECTION_GUID_DEFINED type section...
[mirror_edk2.git] / MdeModulePkg / Core / Dxe / SectionExtraction / CoreSectionExtraction.c
index 2b17239d304a8aea3aed8edfc721b4ec7ddf70d1..243b6b27aeccdadb0c4384a2739307330f38f3ea 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 - 2008, 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
@@ -43,7 +43,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 //\r
 // Local defines and typedefs\r
 //\r
-#define CORE_SECTION_CHILD_SIGNATURE  EFI_SIGNATURE_32('S','X','C','S')\r
+#define CORE_SECTION_CHILD_SIGNATURE  SIGNATURE_32('S','X','C','S')\r
 #define CHILD_SECTION_NODE_FROM_LINK(Node) \\r
   CR (Node, CORE_SECTION_CHILD_NODE, Link, CORE_SECTION_CHILD_SIGNATURE)\r
 \r
@@ -68,7 +68,7 @@ typedef struct {
   EFI_GUID                    *EncapsulationGuid;\r
 } CORE_SECTION_CHILD_NODE;\r
 \r
-#define CORE_SECTION_STREAM_SIGNATURE EFI_SIGNATURE_32('S','X','S','S')\r
+#define CORE_SECTION_STREAM_SIGNATURE SIGNATURE_32('S','X','S','S')\r
 #define STREAM_NODE_FROM_LINK(Node) \\r
   CR (Node, CORE_SECTION_STREAM_NODE, Link, CORE_SECTION_STREAM_SIGNATURE)\r
 \r
@@ -471,7 +471,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
@@ -580,8 +580,8 @@ CreateChildNode (
           // Decompress the stream\r
           //\r
           Status = CoreLocateProtocol (&gEfiDecompressProtocolGuid, NULL, (VOID **)&Decompress);\r
-\r
           ASSERT_EFI_ERROR (Status);\r
+          ASSERT (Decompress != NULL);\r
 \r
           Status = Decompress->GetInfo (\r
                                  Decompress,\r
@@ -635,7 +635,7 @@ CreateChildNode (
       GuidedHeader = (EFI_GUID_DEFINED_SECTION *) SectionHeader;\r
       Node->EncapsulationGuid = &GuidedHeader->SectionDefinitionGuid;\r
       Status = CoreLocateProtocol (Node->EncapsulationGuid, NULL, (VOID **)&GuidedExtraction);\r
-      if (!EFI_ERROR (Status)) {\r
+      if (!EFI_ERROR (Status) && GuidedExtraction != NULL) {\r
         //\r
         // NewStreamBuffer is always allocated by ExtractSection... No caller\r
         // allocation here.\r
@@ -807,6 +807,7 @@ FindChildNode (
   CurrentChildNode = CHILD_SECTION_NODE_FROM_LINK (GetFirstNode(&SourceStream->Children));\r
 \r
   for (;;) {\r
+    ASSERT (CurrentChildNode != NULL);\r
     if (ChildIsType (SourceStream, CurrentChildNode, SearchType, SectionDefinitionGuid)) {\r
       //\r
       // The type matches, so check the instance count to see if it's the one we want\r