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