summaryrefslogtreecommitdiffstats
path: root/MdeModulePkg/Library/UefiHiiLib
diff options
context:
space:
mode:
authorBi, Dandan <dandan.bi@intel.com>2017-08-29 14:44:37 +0800
committerEric Dong <eric.dong@intel.com>2017-08-29 15:57:12 +0800
commit1696b221b15e439162cfccd6bd04132e425dd2ff (patch)
tree430ed8cf2147e5d48f7232221d984cfa84e986af /MdeModulePkg/Library/UefiHiiLib
parent2f208e59e4b994978a1a24affc306eb694a00327 (diff)
downloadedk2-1696b221b15e439162cfccd6bd04132e425dd2ff.tar.gz
edk2-1696b221b15e439162cfccd6bd04132e425dd2ff.tar.bz2
edk2-1696b221b15e439162cfccd6bd04132e425dd2ff.zip
MdeModulePkg/UefiHiiLib: Fix incorrect check for string length
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=681 For string opcode,when checking the valid string length, it should exclude the Null-terminated character. And for string in NameValue storage, need to exclude the varname and also need to convert the Config string length to Unicode string length. Cc: Eric Dong <eric.dong@intel.com> Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Dandan Bi <dandan.bi@intel.com> Reviewed-by: Eric Dong <eric.dong@intel.com>
Diffstat (limited to 'MdeModulePkg/Library/UefiHiiLib')
-rw-r--r--MdeModulePkg/Library/UefiHiiLib/HiiLib.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/MdeModulePkg/Library/UefiHiiLib/HiiLib.c b/MdeModulePkg/Library/UefiHiiLib/HiiLib.c
index cd0cd35a0f..583b9e516c 100644
--- a/MdeModulePkg/Library/UefiHiiLib/HiiLib.c
+++ b/MdeModulePkg/Library/UefiHiiLib/HiiLib.c
@@ -1607,7 +1607,7 @@ ValidateQuestionFromVfr (
break;
}
//
- // Get Width by OneOf Flags
+ // Get the Max size of the string.
//
Width = (UINT16) (IfrString->MaxSize * sizeof (UINT16));
if (NameValueType) {
@@ -1621,6 +1621,10 @@ ValidateQuestionFromVfr (
//
break;
}
+ //
+ // Skip the VarName.
+ //
+ StringPtr += StrLen (QuestionName);
//
// Skip the "=".
@@ -1629,8 +1633,13 @@ ValidateQuestionFromVfr (
//
// Check current string length is less than maxsize
+ // e.g Config String: "0041004200430044", Unicode String: "ABCD". Unicode String length = Config String length / 4.
+ // Config string format in UEFI spec.
+ // <NvConfig> ::= <Label>'='<String>
+ // <String> ::= [<Char>]+
+ // <Char> ::= <HexCh>4
//
- if (StrSize (StringPtr) > Width) {
+ if (StrLen (StringPtr) / 4 > IfrString->MaxSize) {
return EFI_INVALID_PARAMETER;
}
} else {
@@ -1660,7 +1669,7 @@ ValidateQuestionFromVfr (
//
// Check current string length is less than maxsize
//
- if (StrSize ((CHAR16 *) (VarBuffer + Offset)) > Width) {
+ if (StrLen ((CHAR16 *) (VarBuffer + Offset)) > IfrString->MaxSize) {
return EFI_INVALID_PARAMETER;
}
}