Add support to original EFI_IFR_FORM_SET in initial UEFI2.1 spec. Now, it has been...
authorlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 2 Feb 2010 01:38:00 +0000 (01:38 +0000)
committerlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 2 Feb 2010 01:38:00 +0000 (01:38 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk@9906 6f19259b-4bc3-4df7-8a09-765794883524

edk2/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c
edk2/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c

index 161e154..8a53c63 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 Parser for IFR binary encoding.\r
 \r
-Copyright (c) 2007 - 2009, Intel Corporation\r
+Copyright (c) 2007 - 2010, Intel Corporation\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
@@ -1110,11 +1110,13 @@ ParseOpCodes (
       CopyMem (&FormSet->FormSetTitle, &((EFI_IFR_FORM_SET *) OpCodeData)->FormSetTitle, sizeof (EFI_STRING_ID));\r
       CopyMem (&FormSet->Help,         &((EFI_IFR_FORM_SET *) OpCodeData)->Help,         sizeof (EFI_STRING_ID));\r
 \r
-      //\r
-      // The formset OpCode contains ClassGuid\r
-      //\r
-      FormSet->NumberOfClassGuid = (UINT8) (((EFI_IFR_FORM_SET *) OpCodeData)->Flags & 0x3);\r
-      CopyMem (FormSet->ClassGuid, OpCodeData + sizeof (EFI_IFR_FORM_SET), FormSet->NumberOfClassGuid * sizeof (EFI_GUID));\r
+      if (OpCodeLength > OFFSET_OF (EFI_IFR_FORM_SET, Flags)) {\r
+        //\r
+        // The formset OpCode contains ClassGuid\r
+        //\r
+        FormSet->NumberOfClassGuid = (UINT8) (((EFI_IFR_FORM_SET *) OpCodeData)->Flags & 0x3);\r
+        CopyMem (FormSet->ClassGuid, OpCodeData + sizeof (EFI_IFR_FORM_SET), FormSet->NumberOfClassGuid * sizeof (EFI_GUID));\r
+      }\r
 \r
       InitializeListHead (&FormSet->ExpressionListHead);\r
       break;\r
index 36ed98c..ab98ada 100644 (file)
@@ -2461,18 +2461,23 @@ GetIfrBinaryData (
             break;\r
           }\r
 \r
-          //\r
-          // Try to compare against formset class GUID\r
-          //\r
-          NumberOfClassGuid = (UINT8) (((EFI_IFR_FORM_SET *) OpCodeData)->Flags & 0x3);\r
-          ClassGuid         = (EFI_GUID *) (OpCodeData + sizeof (EFI_IFR_FORM_SET));\r
-          for (Index = 0; Index < NumberOfClassGuid; Index++) {\r
-            if (CompareGuid (ComparingGuid, ClassGuid + Index)) {\r
-              ClassGuidMatch = TRUE;\r
+          if (((EFI_IFR_OP_HEADER *) OpCodeData)->Length > OFFSET_OF (EFI_IFR_FORM_SET, Flags)) {\r
+            //\r
+            // Try to compare against formset class GUID\r
+            //\r
+            NumberOfClassGuid = (UINT8) (((EFI_IFR_FORM_SET *) OpCodeData)->Flags & 0x3);\r
+            ClassGuid         = (EFI_GUID *) (OpCodeData + sizeof (EFI_IFR_FORM_SET));\r
+            for (Index = 0; Index < NumberOfClassGuid; Index++) {\r
+              if (CompareGuid (ComparingGuid, ClassGuid + Index)) {\r
+                ClassGuidMatch = TRUE;\r
+                break;\r
+              }\r
+            }\r
+            if (ClassGuidMatch) {\r
               break;\r
             }\r
-          }\r
-          if (ClassGuidMatch) {\r
+          } else if (ComparingGuid == &gEfiHiiPlatformSetupFormsetGuid) {\r
+            ClassGuidMatch = TRUE;\r
             break;\r
           }\r
         }\r