Hello,

I am running into an issue with HiiValidateSettings (); when my VFR contains a 
string item that is filled with a string of maximum length. In this case the 
validation returns an error because it thinks the string is too long.

During the validation ValidateQuestionFromVfr (); checks if the stringlength is 
valid. The issue is that this uses the "maxsize" value * 2 from the VFR. It 
does this using the StrSize function which includes the trailing terminator. 
This is of course correct. The maxsize from the VFR indicates only the amount 
of characters excluding the terminator.

As a quickfix I changed the ValidateQuestionFromVfr () to take this into 
account but I am doubting if this is the correct solution. Can you shed some 
light here?

Below is the fragment where I see this issue:

            //
            // Get Offset/Width by Question header and OneOf Flags
            //
            Offset = IfrString->Question.VarStoreInfo.VarOffset;
            //
            // Check whether this question is in current block array.
            //
            if (!BlockArrayCheck (CurrentBlockArray, Offset, Width)) {
              //
              // This question is not in the current configuration string. Skip 
it.
              //
              break;
            }
            //
            // Check this var question is in the var storage
            //
            if ((Offset + Width) > VarStoreData.Size) {
              //
              // This question exceeds the var store size.
              //
                  return EFI_INVALID_PARAMETER;
            }

            //
            // Check current string length is less than maxsize
            //
            // Please note we subtract sizeof(CHAR16) here because the StrSize 
returns the length including the terminator
            // while we specify the length in characters in the VFR!
            //
ORG ->                 // if ( (StrSize ((CHAR16 *) (VarBuffer + Offset)) > 
Width) {
CHANGED->            if ( (StrSize ((CHAR16 *) (VarBuffer + Offset)) - 
sizeof(CHAR16)) > Width) {
                  return EFI_INVALID_PARAMETER;
            }
          }
          break;
Best Regards,
Wim Vervoorn

Eltan B.V.
Ambachtstraat 23
5481 SM Schijndel
The Netherlands

T : +31-(0)73-594 46 64
E : [email protected]
W : http://www.eltan.com<http://www.eltan.com/>
"THIS MESSAGE CONTAINS CONFIDENTIAL INFORMATION. UNLESS YOU ARE THE INTENDED 
RECIPIENT OF THIS MESSAGE, ANY USE OF THIS MESSAGE IS STRICTLY PROHIBITED. IF 
YOU HAVE RECEIVED THIS MESSAGE IN ERROR, PLEASE IMMEDIATELY NOTIFY THE SENDER 
BY TELEPHONE +31-(0)73-5944664 OR REPLY EMAIL, AND IMMEDIATELY DELETE THIS 
MESSAGE AND ALL COPIES."


_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to