]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Fix the bug that HiiConfigToBlock doesn't update BlockSize when Block is not large...
authorlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 23 Nov 2010 11:13:22 +0000 (11:13 +0000)
committerlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 23 Nov 2010 11:13:22 +0000 (11:13 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11085 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c

index 2e73924ca1ec9277e24fbc22a030677c667b3992..4f83fe386619b1db67ef6f887543c88ae3be444f 100644 (file)
@@ -3224,6 +3224,10 @@ Exit:
                                  value pair. Block is left updated and\r
                                  Progress points at the '&' preceding the first\r
                                  non-<BlockName>.\r
+  @retval EFI_DEVICE_ERROR       Block not large enough. Progress undefined.\r
+  @retval EFI_NOT_FOUND          Target for the specified routing data was not found.\r
+                                 Progress points to the "G" in "GUID" of the errant\r
+                                 routing data.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -3245,13 +3249,14 @@ HiiConfigToBlock (
   UINTN                               Width;\r
   UINT8                               *Value;\r
   UINTN                               BufferSize;\r
+  UINTN                               MaxBlockSize;\r
 \r
   if (This == NULL || BlockSize == NULL || Progress == NULL) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
-  if (ConfigResp == NULL || Block == NULL) {\r
-    *Progress = ConfigResp;\r
+  *Progress = ConfigResp;\r
+  if (ConfigResp == NULL) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
@@ -3261,6 +3266,7 @@ HiiConfigToBlock (
   StringPtr  = ConfigResp;\r
   BufferSize = *BlockSize;\r
   Value      = NULL;\r
+  MaxBlockSize = 0;\r
 \r
   //\r
   // Jump <ConfigHdr>\r
@@ -3366,13 +3372,12 @@ HiiConfigToBlock (
     //\r
     // Update the Block with configuration info\r
     //\r
-\r
-    if (Offset + Width > BufferSize) {\r
-      return EFI_DEVICE_ERROR;\r
+    if ((Block != NULL) && (Offset + Width <= BufferSize)) {\r
+      CopyMem (Block + Offset, Value, Width);\r
+    }\r
+    if (Offset + Width > MaxBlockSize) {\r
+      MaxBlockSize = Offset + Width;\r
     }\r
-\r
-    CopyMem (Block + Offset, Value, Width);\r
-    *BlockSize = Offset + Width - 1;\r
 \r
     FreePool (Value);\r
     Value = NULL;\r
@@ -3397,6 +3402,17 @@ HiiConfigToBlock (
   }\r
 \r
   *Progress = StringPtr + StrLen (StringPtr);\r
+  *BlockSize = MaxBlockSize - 1;\r
+\r
+  if (MaxBlockSize > BufferSize) {\r
+    *BlockSize = MaxBlockSize;\r
+    if (Block == NULL) {\r
+      return EFI_INVALID_PARAMETER;\r
+    } else {\r
+      return EFI_DEVICE_ERROR;\r
+    }\r
+  }\r
+\r
   return EFI_SUCCESS;\r
 \r
 Exit:\r