From e0d1b0366bccdbdd48137d7e1574611233495da8 Mon Sep 17 00:00:00 2001 From: Dandan Bi Date: Tue, 19 Nov 2024 16:56:28 +0800 Subject: [PATCH] MdeModulePkg/HiiDatabase: Return default value for BIT VarStore as UNIT32 REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4874 Question CheckBox, OneOf and Numeric can refer to Bit EFI VarStore CheckBox: data type is Boolean (1 byte) Numeric/Oneof: data type is always UNIT32 for BIT VarStore When get default value for BIT VarStore, should return default value with sizeof (UINT32) rather than the byte the bit width occupied. Or incorrect default value will be used due to the size mismatch. Signed-off-by: Dandan Bi --- MdeModulePkg/Universal/HiiDatabaseDxe/Database.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c b/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c index ac0cb7e77374..09aefc662ad5 100644 --- a/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c @@ -825,7 +825,7 @@ FindQuestionDefaultSetting ( if (BitFieldQuestion) { CopyMem (&BufferValue, (UINT8 *)AuthVariableHeader + sizeof (AUTHENTICATED_VARIABLE_HEADER) + AuthVariableHeader->NameSize + ByteOffset, Width); BitFieldVal = BitFieldRead32 (BufferValue, StartBit, EndBit); - CopyMem (ValueBuffer, &BitFieldVal, Width); + CopyMem (ValueBuffer, &BitFieldVal, sizeof (UINT32)); } else { CopyMem (ValueBuffer, (UINT8 *)AuthVariableHeader + sizeof (AUTHENTICATED_VARIABLE_HEADER) + AuthVariableHeader->NameSize + IfrQuestionHdr->VarStoreInfo.VarOffset, Width); } @@ -862,7 +862,7 @@ FindQuestionDefaultSetting ( if (BitFieldQuestion) { CopyMem (&BufferValue, (UINT8 *)VariableHeader + sizeof (VARIABLE_HEADER) + VariableHeader->NameSize + ByteOffset, Width); BitFieldVal = BitFieldRead32 (BufferValue, StartBit, EndBit); - CopyMem (ValueBuffer, &BitFieldVal, Width); + CopyMem (ValueBuffer, &BitFieldVal, sizeof (UINT32)); } else { CopyMem (ValueBuffer, (UINT8 *)VariableHeader + sizeof (VARIABLE_HEADER) + VariableHeader->NameSize + IfrQuestionHdr->VarStoreInfo.VarOffset, Width); }