X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=MdeModulePkg%2FUniversal%2FDisplayEngineDxe%2FProcessOptions.c;h=557e8ecd9466af49ec051db2e34fb5dd16fb41f2;hb=7155d0a68c37461dcf5f39876d145799be481744;hp=84ae03eea70fb3d01b6f361ddd3efd02b5904cb1;hpb=42645c3dcf0488c616422dcdfd1596939223f432;p=mirror_edk2.git diff --git a/MdeModulePkg/Universal/DisplayEngineDxe/ProcessOptions.c b/MdeModulePkg/Universal/DisplayEngineDxe/ProcessOptions.c index 84ae03eea7..557e8ecd94 100644 --- a/MdeModulePkg/Universal/DisplayEngineDxe/ProcessOptions.c +++ b/MdeModulePkg/Universal/DisplayEngineDxe/ProcessOptions.c @@ -2,7 +2,7 @@ Implementation for handling the User Interface option processing. -Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -21,6 +21,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. Concatenate a narrow string to another string. @param Destination The destination string. + @param DestMax The Max length of destination string. @param Source The source string. The string to be concatenated. to the end of Destination. @@ -28,6 +29,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. VOID NewStrCat ( IN OUT CHAR16 *Destination, + IN UINTN DestMax, IN CHAR16 *Source ) { @@ -45,7 +47,7 @@ NewStrCat ( Destination[Length] = NARROW_CHAR; Length++; - StrCpy (Destination + Length, Source); + StrCpyS (Destination + Length, DestMax - Length, Source); } /** @@ -566,7 +568,6 @@ PrintFormattedNumber ( default: return EFI_UNSUPPORTED; - break; } UnicodeSPrint (FormattedNumber, BufferSize, Format, Value); @@ -813,6 +814,11 @@ PasswordProcess ( // // Password can't be set now. // + if (Status == EFI_UNSUPPORTED) { + do { + CreateDialog (&Key, gEmptyString, gPasswordUnsupported, gPressEnter, gEmptyString, NULL); + } while (Key.UnicodeChar != CHAR_CARRIAGE_RETURN); + } FreePool (StringPtr); return EFI_SUCCESS; } @@ -884,18 +890,8 @@ PasswordProcess ( gUserInput->InputValue.BufferLen = Question->CurrentValue.BufferLen; gUserInput->InputValue.Type = Question->CurrentValue.Type; gUserInput->InputValue.Value.string = HiiSetString(gFormData->HiiHandle, gUserInput->InputValue.Value.string, StringPtr, NULL); - FreePool (StringPtr); Status = EFI_SUCCESS; - - if (EFI_ERROR (Status)) { - // - // Reset state machine for password - // - Question->PasswordCheck (gFormData, Question, NULL); - } - - return Status; } else { // // Reset state machine for password @@ -911,7 +907,8 @@ PasswordProcess ( Status = EFI_INVALID_PARAMETER; } - + ZeroMem (TempString, (Maximum + 1) * sizeof (CHAR16)); + ZeroMem (StringPtr, (Maximum + 1) * sizeof (CHAR16)); FreePool (TempString); FreePool (StringPtr); @@ -957,6 +954,7 @@ ProcessOptions ( UINT8 ValueType; EFI_IFR_ORDERED_LIST *OrderList; BOOLEAN ValueInvalid; + UINTN MaxLen; Status = EFI_SUCCESS; @@ -999,7 +997,8 @@ ProcessOptions ( // We now know how many strings we will have, so we can allocate the // space required for the array or strings. // - *OptionString = AllocateZeroPool (OrderList->MaxContainers * BufferSize); + MaxLen = OrderList->MaxContainers * BufferSize / sizeof (CHAR16); + *OptionString = AllocateZeroPool (MaxLen * sizeof (CHAR16)); ASSERT (*OptionString); HiiValue.Type = ValueType; @@ -1057,14 +1056,14 @@ ProcessOptions ( } Character[0] = LEFT_ONEOF_DELIMITER; - NewStrCat (OptionString[0], Character); + NewStrCat (OptionString[0], MaxLen, Character); StringPtr = GetToken (OneOfOption->OptionOpCode->Option, gFormData->HiiHandle); ASSERT (StringPtr != NULL); - NewStrCat (OptionString[0], StringPtr); + NewStrCat (OptionString[0], MaxLen, StringPtr); Character[0] = RIGHT_ONEOF_DELIMITER; - NewStrCat (OptionString[0], Character); + NewStrCat (OptionString[0], MaxLen, Character); Character[0] = CHAR_CARRIAGE_RETURN; - NewStrCat (OptionString[0], Character); + NewStrCat (OptionString[0], MaxLen, Character); FreePool (StringPtr); } @@ -1092,14 +1091,14 @@ ProcessOptions ( // Not report error, just get the correct option string info. // Character[0] = LEFT_ONEOF_DELIMITER; - NewStrCat (OptionString[0], Character); + NewStrCat (OptionString[0], MaxLen, Character); StringPtr = GetToken (OneOfOption->OptionOpCode->Option, gFormData->HiiHandle); ASSERT (StringPtr != NULL); - NewStrCat (OptionString[0], StringPtr); + NewStrCat (OptionString[0], MaxLen, StringPtr); Character[0] = RIGHT_ONEOF_DELIMITER; - NewStrCat (OptionString[0], Character); + NewStrCat (OptionString[0], MaxLen, Character); Character[0] = CHAR_CARRIAGE_RETURN; - NewStrCat (OptionString[0], Character); + NewStrCat (OptionString[0], MaxLen, Character); FreePool (StringPtr); continue; @@ -1151,6 +1150,7 @@ ProcessOptions ( // Status = GetSelectionInputPopUp (MenuOption); } else { + MaxLen = BufferSize / sizeof(CHAR16); *OptionString = AllocateZeroPool (BufferSize); ASSERT (*OptionString); @@ -1204,12 +1204,12 @@ ProcessOptions ( } Character[0] = LEFT_ONEOF_DELIMITER; - NewStrCat (OptionString[0], Character); + NewStrCat (OptionString[0], MaxLen, Character); StringPtr = GetToken (OneOfOption->OptionOpCode->Option, gFormData->HiiHandle); ASSERT (StringPtr != NULL); - NewStrCat (OptionString[0], StringPtr); + NewStrCat (OptionString[0], MaxLen, StringPtr); Character[0] = RIGHT_ONEOF_DELIMITER; - NewStrCat (OptionString[0], Character); + NewStrCat (OptionString[0], MaxLen, Character); FreePool (StringPtr); } @@ -1278,19 +1278,31 @@ ProcessOptions ( switch (MenuOption->Sequence) { case 0: *OptionString[0] = LEFT_NUMERIC_DELIMITER; - UnicodeSPrint (OptionString[0] + 1, 21 * sizeof (CHAR16), L"%02d", QuestionValue->Value.date.Month); + if (QuestionValue->Value.date.Month == 0xff){ + UnicodeSPrint (OptionString[0] + 1, 21 * sizeof (CHAR16), L"??"); + } else { + UnicodeSPrint (OptionString[0] + 1, 21 * sizeof (CHAR16), L"%02d", QuestionValue->Value.date.Month); + } *(OptionString[0] + 3) = DATE_SEPARATOR; break; case 1: SetUnicodeMem (OptionString[0], 4, L' '); - UnicodeSPrint (OptionString[0] + 4, 21 * sizeof (CHAR16), L"%02d", QuestionValue->Value.date.Day); + if (QuestionValue->Value.date.Day == 0xff){ + UnicodeSPrint (OptionString[0] + 4, 21 * sizeof (CHAR16), L"??"); + } else { + UnicodeSPrint (OptionString[0] + 4, 21 * sizeof (CHAR16), L"%02d", QuestionValue->Value.date.Day); + } *(OptionString[0] + 6) = DATE_SEPARATOR; break; case 2: SetUnicodeMem (OptionString[0], 7, L' '); - UnicodeSPrint (OptionString[0] + 7, 21 * sizeof (CHAR16), L"%04d", QuestionValue->Value.date.Year); + if (QuestionValue->Value.date.Year == 0xff){ + UnicodeSPrint (OptionString[0] + 7, 21 * sizeof (CHAR16), L"????"); + } else { + UnicodeSPrint (OptionString[0] + 7, 21 * sizeof (CHAR16), L"%04d", QuestionValue->Value.date.Year); + } *(OptionString[0] + 11) = RIGHT_NUMERIC_DELIMITER; break; } @@ -1310,19 +1322,31 @@ ProcessOptions ( switch (MenuOption->Sequence) { case 0: *OptionString[0] = LEFT_NUMERIC_DELIMITER; - UnicodeSPrint (OptionString[0] + 1, 21 * sizeof (CHAR16), L"%02d", QuestionValue->Value.time.Hour); + if (QuestionValue->Value.time.Hour == 0xff){ + UnicodeSPrint (OptionString[0] + 1, 21 * sizeof (CHAR16), L"??"); + } else { + UnicodeSPrint (OptionString[0] + 1, 21 * sizeof (CHAR16), L"%02d", QuestionValue->Value.time.Hour); + } *(OptionString[0] + 3) = TIME_SEPARATOR; break; case 1: SetUnicodeMem (OptionString[0], 4, L' '); - UnicodeSPrint (OptionString[0] + 4, 21 * sizeof (CHAR16), L"%02d", QuestionValue->Value.time.Minute); + if (QuestionValue->Value.time.Minute == 0xff){ + UnicodeSPrint (OptionString[0] + 4, 21 * sizeof (CHAR16), L"??"); + } else { + UnicodeSPrint (OptionString[0] + 4, 21 * sizeof (CHAR16), L"%02d", QuestionValue->Value.time.Minute); + } *(OptionString[0] + 6) = TIME_SEPARATOR; break; case 2: SetUnicodeMem (OptionString[0], 7, L' '); - UnicodeSPrint (OptionString[0] + 7, 21 * sizeof (CHAR16), L"%02d", QuestionValue->Value.time.Second); + if (QuestionValue->Value.time.Second == 0xff){ + UnicodeSPrint (OptionString[0] + 7, 21 * sizeof (CHAR16), L"??"); + } else { + UnicodeSPrint (OptionString[0] + 7, 21 * sizeof (CHAR16), L"%02d", QuestionValue->Value.time.Second); + } *(OptionString[0] + 9) = RIGHT_NUMERIC_DELIMITER; break; }