From 580d230d12e16651494ce622bee93591e7fe5491 Mon Sep 17 00:00:00 2001 From: Eric Dong Date: Thu, 17 Sep 2015 01:20:37 +0000 Subject: [PATCH] MdeModulePkg/HiiDatabase: Refine KeywordHandlerProtocol->SetData(). Update this function to follow UEFI spec requirement. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Eric Dong Reviewed-by: Liming Gao git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18490 6f19259b-4bc3-4df7-8a09-765794883524 --- .../HiiDatabaseDxe/ConfigKeywordHandler.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigKeywordHandler.c b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigKeywordHandler.c index b978669687..6923d6c473 100644 --- a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigKeywordHandler.c +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigKeywordHandler.c @@ -2829,6 +2829,7 @@ EfiConfigKeywordHandlerSetData ( BOOLEAN ReadOnly; EFI_STRING InternalProgress; CHAR16 *TempString; + CHAR16 *KeywordStartPos; if (This == NULL || Progress == NULL || ProgressErr == NULL || KeywordString == NULL) { return EFI_INVALID_PARAMETER; @@ -2843,6 +2844,7 @@ EfiConfigKeywordHandlerSetData ( KeywordData = NULL; ValueElement = NULL; ConfigResp = NULL; + KeywordStartPos = NULL; KeywordStringId = 0; // @@ -2886,6 +2888,7 @@ EfiConfigKeywordHandlerSetData ( // // 3. Extract keyword from the KeywordRequest string. // + KeywordStartPos = StringPtr; Status = ExtractKeyword(StringPtr, &KeywordData, &NextStringPtr); if (EFI_ERROR (Status)) { // @@ -2942,8 +2945,8 @@ EfiConfigKeywordHandlerSetData ( // 8. Check the readonly flag. // if (ExtractReadOnlyFromOpCode (OpCode) != ReadOnly) { - *ProgressErr = KEYWORD_HANDLER_INCOMPATIBLE_VALUE_DETECTED; - Status = EFI_INVALID_PARAMETER; + *ProgressErr = KEYWORD_HANDLER_ACCESS_NOT_PERMITTED; + Status = EFI_ACCESS_DENIED; goto Done; } @@ -2970,6 +2973,7 @@ EfiConfigKeywordHandlerSetData ( FreePool (ConfigResp); ConfigResp = NULL; } + KeywordStartPos = NULL; } // @@ -2988,7 +2992,11 @@ EfiConfigKeywordHandlerSetData ( *ProgressErr = KEYWORD_HANDLER_NO_ERROR; Done: - *Progress = KeywordString + (StringPtr - TempString); + if (KeywordStartPos != NULL) { + *Progress = KeywordString + (KeywordStartPos - TempString); + } else { + *Progress = KeywordString + (StringPtr - TempString); + } ASSERT (TempString != NULL); FreePool (TempString); @@ -3010,7 +3018,7 @@ Done: if (MultiConfigResp != NULL && MultiConfigResp != ConfigResp) { FreePool (MultiConfigResp); } - + return Status; }