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 <eric.dong@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18490 6f19259b-4bc3-4df7-8a09-765794883524
diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigKeywordHandler.c b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigKeywordHandler.c
index b978669..6923d6c 100644
--- a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigKeywordHandler.c
+++ b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigKeywordHandler.c
@@ -2829,6 +2829,7 @@
   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 @@
   KeywordData     = NULL;

   ValueElement    = NULL;

   ConfigResp      = NULL;

+  KeywordStartPos = NULL;

   KeywordStringId = 0;

 

   //

@@ -2886,6 +2888,7 @@
     //

     // 3. Extract keyword from the KeywordRequest string.

     //

+    KeywordStartPos = StringPtr;

     Status = ExtractKeyword(StringPtr, &KeywordData, &NextStringPtr);

     if (EFI_ERROR (Status)) {

       //

@@ -2942,8 +2945,8 @@
     // 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 @@
       FreePool (ConfigResp);

       ConfigResp = NULL;

     }

+    KeywordStartPos = NULL;

   }

 

   //

@@ -2988,7 +2992,11 @@
   *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 @@
   if (MultiConfigResp != NULL && MultiConfigResp != ConfigResp) {

     FreePool (MultiConfigResp);

   }

-  

+

   return Status;

 }