X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=MdeModulePkg%2FUniversal%2FSetupBrowserDxe%2FIfrParse.c;h=e806b504b2934fdc4079d02b928dd862f48db7ca;hb=4f467fd33b2fc682ed5f1932453d47110345534e;hp=ed06f1c9cd0811706a8e4ca51cd7a9ce3eb78959;hpb=077c7aeec07361fc36f8090be46959adb7d38873;p=mirror_edk2.git diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c b/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c index ed06f1c9cd..e806b504b2 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c +++ b/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c @@ -286,13 +286,15 @@ CreateQuestion ( Allocate a FORM_EXPRESSION node. @param Form The Form associated with this Expression + @param OpCode The binary opcode data. @return Pointer to a FORM_EXPRESSION data structure. **/ FORM_EXPRESSION * CreateExpression ( - IN OUT FORM_BROWSER_FORM *Form + IN OUT FORM_BROWSER_FORM *Form, + IN UINT8 *OpCode ) { FORM_EXPRESSION *Expression; @@ -301,6 +303,7 @@ CreateExpression ( ASSERT (Expression != NULL); Expression->Signature = FORM_EXPRESSION_SIGNATURE; InitializeListHead (&Expression->OpCodeListHead); + Expression->OpCode = (EFI_IFR_OP_HEADER *) OpCode; return Expression; } @@ -1070,6 +1073,23 @@ IsStatementOpCode ( } } +/** + Tell whether this Operand is an known OpCode. + + @param Operand Operand of an IFR OpCode. + + @retval TRUE This is an Statement OpCode. + @retval FALSE Not an Statement OpCode. + +**/ +BOOLEAN +IsUnKnownOpCode ( + IN UINT8 Operand + ) +{ + return Operand > EFI_IFR_WARNING_IF_OP ? TRUE : FALSE; +} + /** Calculate number of Statemens(Questions) and Expression OpCodes. @@ -1162,6 +1182,8 @@ ParseOpCodes ( EFI_VARSTORE_ID TempVarstoreId; BOOLEAN InScopeDisable; INTN ConditionalExprCount; + BOOLEAN InUnknownScope; + UINT8 UnknownDepth; SuppressForQuestion = FALSE; SuppressForOption = FALSE; @@ -1181,6 +1203,8 @@ ParseOpCodes ( MapExpressionList = NULL; TempVarstoreId = 0; ConditionalExprCount = 0; + InUnknownScope = FALSE; + UnknownDepth = 0; // // Get the number of Statements and Expressions @@ -1223,6 +1247,31 @@ ParseOpCodes ( Operand = ((EFI_IFR_OP_HEADER *) OpCodeData)->OpCode; Scope = ((EFI_IFR_OP_HEADER *) OpCodeData)->Scope; + if (InUnknownScope) { + if (Operand == EFI_IFR_END_OP) { + UnknownDepth --; + + if (UnknownDepth == 0) { + InUnknownScope = FALSE; + } + } else { + if (Scope != 0) { + UnknownDepth ++; + } + } + + continue; + } + + if (IsUnKnownOpCode(Operand)) { + if (Scope != 0) { + InUnknownScope = TRUE; + UnknownDepth ++; + } + + continue; + } + // // If scope bit set, push onto scope stack // @@ -1466,7 +1515,7 @@ ParseOpCodes ( // Create sub expression nested in MAP opcode // if (CurrentExpression == NULL && MapScopeDepth > 0) { - CurrentExpression = CreateExpression (CurrentForm); + CurrentExpression = CreateExpression (CurrentForm, OpCodeData); ASSERT (MapExpressionList != NULL); InsertTailList (MapExpressionList, &CurrentExpression->Link); if (Scope == 0) { @@ -1510,11 +1559,7 @@ ParseOpCodes ( return Status; } - if (CurrentExpression->Result.Type != EFI_IFR_TYPE_BOOLEAN) { - return EFI_INVALID_PARAMETER; - } - - OpCodeDisabled = CurrentExpression->Result.Value.b; + OpCodeDisabled = IsTrue(&CurrentExpression->Result); } CurrentExpression = NULL; @@ -2048,7 +2093,7 @@ ParseOpCodes ( // // Create an Expression node // - CurrentExpression = CreateExpression (CurrentForm); + CurrentExpression = CreateExpression (CurrentForm, OpCodeData); CopyMem (&CurrentExpression->Error, &((EFI_IFR_INCONSISTENT_IF *) OpCodeData)->Error, sizeof (EFI_STRING_ID)); if (Operand == EFI_IFR_NO_SUBMIT_IF_OP) { @@ -2072,7 +2117,7 @@ ParseOpCodes ( // // Create an Expression node // - CurrentExpression = CreateExpression (CurrentForm); + CurrentExpression = CreateExpression (CurrentForm, OpCodeData); CopyMem (&CurrentExpression->Error, &((EFI_IFR_WARNING_IF *) OpCodeData)->Warning, sizeof (EFI_STRING_ID)); CurrentExpression->TimeOut = ((EFI_IFR_WARNING_IF *) OpCodeData)->TimeOut; CurrentExpression->Type = EFI_HII_EXPRESSION_WARNING_IF; @@ -2091,7 +2136,7 @@ ParseOpCodes ( // // Question and Option will appear in scope of this OpCode // - CurrentExpression = CreateExpression (CurrentForm); + CurrentExpression = CreateExpression (CurrentForm, OpCodeData); CurrentExpression->Type = EFI_HII_EXPRESSION_SUPPRESS_IF; if (CurrentForm == NULL) { @@ -2121,7 +2166,7 @@ ParseOpCodes ( // // Questions will appear in scope of this OpCode // - CurrentExpression = CreateExpression (CurrentForm); + CurrentExpression = CreateExpression (CurrentForm, OpCodeData); CurrentExpression->Type = EFI_HII_EXPRESSION_GRAY_OUT_IF; InsertTailList (&CurrentForm->ExpressionListHead, &CurrentExpression->Link); PushConditionalExpression(CurrentExpression, ExpressStatement); @@ -2169,7 +2214,7 @@ ParseOpCodes ( // Expression // case EFI_IFR_VALUE_OP: - CurrentExpression = CreateExpression (CurrentForm); + CurrentExpression = CreateExpression (CurrentForm, OpCodeData); CurrentExpression->Type = EFI_HII_EXPRESSION_VALUE; InsertTailList (&CurrentForm->ExpressionListHead, &CurrentExpression->Link); @@ -2201,7 +2246,7 @@ ParseOpCodes ( break; case EFI_IFR_RULE_OP: - CurrentExpression = CreateExpression (CurrentForm); + CurrentExpression = CreateExpression (CurrentForm, OpCodeData); CurrentExpression->Type = EFI_HII_EXPRESSION_RULE; CurrentExpression->RuleId = ((EFI_IFR_RULE *) OpCodeData)->RuleId; @@ -2217,7 +2262,7 @@ ParseOpCodes ( break; case EFI_IFR_READ_OP: - CurrentExpression = CreateExpression (CurrentForm); + CurrentExpression = CreateExpression (CurrentForm, OpCodeData); CurrentExpression->Type = EFI_HII_EXPRESSION_READ; InsertTailList (&CurrentForm->ExpressionListHead, &CurrentExpression->Link); @@ -2239,7 +2284,7 @@ ParseOpCodes ( break; case EFI_IFR_WRITE_OP: - CurrentExpression = CreateExpression (CurrentForm); + CurrentExpression = CreateExpression (CurrentForm, OpCodeData); CurrentExpression->Type = EFI_HII_EXPRESSION_WRITE; InsertTailList (&CurrentForm->ExpressionListHead, &CurrentExpression->Link); @@ -2366,7 +2411,7 @@ ParseOpCodes ( // // Parent statement end tag found, update ParentStatement info. // - if (IsStatementOpCode(ScopeOpCode) && ParentStatement->Operand == ScopeOpCode) { + if (IsStatementOpCode(ScopeOpCode) && (ParentStatement != NULL) && (ParentStatement->Operand == ScopeOpCode)) { ParentStatement = ParentStatement->ParentStatement; } @@ -2463,11 +2508,8 @@ ParseOpCodes ( return Status; } - if (CurrentExpression->Result.Type != EFI_IFR_TYPE_BOOLEAN) { - return EFI_INVALID_PARAMETER; - } + OpCodeDisabled = IsTrue (&CurrentExpression->Result); - OpCodeDisabled = CurrentExpression->Result.Value.b; // // DisableIf Expression is only used once and not queued, free it //