diff options
author | lgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524> | 2010-11-23 11:13:22 +0000 |
---|---|---|
committer | lgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524> | 2010-11-23 11:13:22 +0000 |
commit | 09b794172ec8efcbc00c0ada499e2ef646a10f47 (patch) | |
tree | c669f4b4e068e4a6d7b9473efd235fd4c2c05be6 /MdeModulePkg | |
parent | 8185265e691a25ab98198b63333a40bfaac57422 (diff) | |
download | edk2-09b794172ec8efcbc00c0ada499e2ef646a10f47.zip edk2-09b794172ec8efcbc00c0ada499e2ef646a10f47.tar.gz edk2-09b794172ec8efcbc00c0ada499e2ef646a10f47.tar.bz2 |
Fix the bug that HiiConfigToBlock doesn't update BlockSize when Block is not large enough
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11085 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdeModulePkg')
-rw-r--r-- | MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c index 2e73924..4f83fe3 100644 --- a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c @@ -3224,6 +3224,10 @@ Exit: value pair. Block is left updated and
Progress points at the '&' preceding the first
non-<BlockName>.
+ @retval EFI_DEVICE_ERROR Block not large enough. Progress undefined.
+ @retval EFI_NOT_FOUND Target for the specified routing data was not found.
+ Progress points to the "G" in "GUID" of the errant
+ routing data.
**/
EFI_STATUS
@@ -3245,13 +3249,14 @@ HiiConfigToBlock ( UINTN Width;
UINT8 *Value;
UINTN BufferSize;
+ UINTN MaxBlockSize;
if (This == NULL || BlockSize == NULL || Progress == NULL) {
return EFI_INVALID_PARAMETER;
}
- if (ConfigResp == NULL || Block == NULL) {
- *Progress = ConfigResp;
+ *Progress = ConfigResp;
+ if (ConfigResp == NULL) {
return EFI_INVALID_PARAMETER;
}
@@ -3261,6 +3266,7 @@ HiiConfigToBlock ( StringPtr = ConfigResp;
BufferSize = *BlockSize;
Value = NULL;
+ MaxBlockSize = 0;
//
// Jump <ConfigHdr>
@@ -3366,13 +3372,12 @@ HiiConfigToBlock ( //
// Update the Block with configuration info
//
-
- if (Offset + Width > BufferSize) {
- return EFI_DEVICE_ERROR;
+ if ((Block != NULL) && (Offset + Width <= BufferSize)) {
+ CopyMem (Block + Offset, Value, Width);
+ }
+ if (Offset + Width > MaxBlockSize) {
+ MaxBlockSize = Offset + Width;
}
-
- CopyMem (Block + Offset, Value, Width);
- *BlockSize = Offset + Width - 1;
FreePool (Value);
Value = NULL;
@@ -3397,6 +3402,17 @@ HiiConfigToBlock ( }
*Progress = StringPtr + StrLen (StringPtr);
+ *BlockSize = MaxBlockSize - 1;
+
+ if (MaxBlockSize > BufferSize) {
+ *BlockSize = MaxBlockSize;
+ if (Block == NULL) {
+ return EFI_INVALID_PARAMETER;
+ } else {
+ return EFI_DEVICE_ERROR;
+ }
+ }
+
return EFI_SUCCESS;
Exit:
|