EmbeddedPkg: Correct the way of handling sections with a large size
authorGe Song <ge.song@hxt-semitech.com>
Thu, 8 Mar 2018 00:55:10 +0000 (08:55 +0800)
committerArd Biesheuvel <ard.biesheuvel@linaro.org>
Tue, 13 Mar 2018 15:26:09 +0000 (15:26 +0000)
Correct the way of handling EFI_SECTION_GUID_DEFINED type sections
with a large size

Cc: Leif Lindholm <leif.lindholm@linaro.org>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ge Song <ge.song@hxt-semitech.com>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
EmbeddedPkg/Library/PrePiExtractGuidedSectionLib/PrePiExtractGuidedSectionLib.c

index 7b08de8..e94f542 100644 (file)
@@ -123,6 +123,7 @@ ExtractGuidedSectionGetInfo (
 {\r
   PRE_PI_EXTRACT_GUIDED_SECTION_DATA  *SavedData;\r
   UINT32                              Index;\r
+  EFI_GUID                            *SectionDefinitionGuid;\r
 \r
   if (InputSection == NULL) {\r
     return RETURN_INVALID_PARAMETER;\r
@@ -134,11 +135,17 @@ ExtractGuidedSectionGetInfo (
 \r
   SavedData = GetSavedData();\r
 \r
+  if (IS_SECTION2 (InputSection)) {\r
+    SectionDefinitionGuid = &(((EFI_GUID_DEFINED_SECTION2 *) InputSection)->SectionDefinitionGuid);\r
+  } else {\r
+    SectionDefinitionGuid = &(((EFI_GUID_DEFINED_SECTION *) InputSection)->SectionDefinitionGuid);\r
+  }\r
+\r
   //\r
   // Search the match registered GetInfo handler for the input guided section.\r
   //\r
   for (Index = 0; Index < SavedData->NumberOfExtractHandler; Index ++) {\r
-    if (CompareGuid (&SavedData->ExtractHandlerGuidTable[Index], &(((EFI_GUID_DEFINED_SECTION *) InputSection)->SectionDefinitionGuid))) {\r
+    if (CompareGuid (&SavedData->ExtractHandlerGuidTable[Index], SectionDefinitionGuid)) {\r
       break;\r
     }\r
   }\r
@@ -172,6 +179,7 @@ ExtractGuidedSectionDecode (
 {\r
   PRE_PI_EXTRACT_GUIDED_SECTION_DATA  *SavedData;\r
   UINT32                              Index;\r
+  EFI_GUID                            *SectionDefinitionGuid;\r
 \r
   if (InputSection == NULL) {\r
     return RETURN_INVALID_PARAMETER;\r
@@ -182,11 +190,17 @@ ExtractGuidedSectionDecode (
 \r
   SavedData = GetSavedData();\r
 \r
+  if (IS_SECTION2 (InputSection)) {\r
+    SectionDefinitionGuid = &(((EFI_GUID_DEFINED_SECTION2 *) InputSection)->SectionDefinitionGuid);\r
+  } else {\r
+    SectionDefinitionGuid = &(((EFI_GUID_DEFINED_SECTION *) InputSection)->SectionDefinitionGuid);\r
+  }\r
+\r
   //\r
   // Search the match registered GetInfo handler for the input guided section.\r
   //\r
   for (Index = 0; Index < SavedData->NumberOfExtractHandler; Index ++) {\r
-    if (CompareGuid (&SavedData->ExtractHandlerGuidTable[Index], &(((EFI_GUID_DEFINED_SECTION *) InputSection)->SectionDefinitionGuid))) {\r
+    if (CompareGuid (&SavedData->ExtractHandlerGuidTable[Index], SectionDefinitionGuid)) {\r
       break;\r
     }\r
   }\r