public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Wim Vervoorn <wvervoorn@eltan.com>
To: "edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Subject: HiiValidateSettings issue with string item
Date: Thu, 24 Aug 2017 06:59:23 +0000	[thread overview]
Message-ID: <03b999a0727d4026a810530b59caeba5@Eltsrv03.Eltan.local> (raw)

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 : wvervoorn@eltan.com
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."




             reply	other threads:[~2017-08-24  6:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-24  6:59 Wim Vervoorn [this message]
2017-08-24  8:35 ` HiiValidateSettings issue with string item Bi, Dandan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=03b999a0727d4026a810530b59caeba5@Eltsrv03.Eltan.local \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox