From 1696b221b15e439162cfccd6bd04132e425dd2ff Mon Sep 17 00:00:00 2001 From: "Bi, Dandan" Date: Tue, 29 Aug 2017 14:44:37 +0800 Subject: [PATCH] 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 Cc: Liming Gao Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Dandan Bi Reviewed-by: Eric Dong --- MdeModulePkg/Library/UefiHiiLib/HiiLib.c | 15 ++++++++++++--- 1 file 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. + // ::=