]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Library/UefiShellDebug1CommandsLib/EditInputBar.c
ShellPkg/for: Fix potential null pointer deference
[mirror_edk2.git] / ShellPkg / Library / UefiShellDebug1CommandsLib / EditInputBar.c
index 978ce7f13a1f403c7cde1dcd4368fb26696f5d3c..26f70d719ab3f0cb79208401c6cfec65d00ec516 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Implements inputbar interface functions.\r
 \r
-  Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved. <BR>\r
+  Copyright (c) 2005 - 2014, 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
@@ -23,7 +23,6 @@ UINTN   StringSize;      // Size of mReturnString space size.
   Initialize the input bar.\r
 **/\r
 VOID\r
-EFIAPI\r
 InputBarInit (\r
   VOID\r
   )\r
@@ -37,7 +36,6 @@ InputBarInit (
   Cleanup function for input bar.\r
 **/\r
 VOID\r
-EFIAPI\r
 InputBarCleanup (\r
   VOID\r
   )\r
@@ -59,7 +57,6 @@ InputBarCleanup (
   @param[in]  LastRow      The last printable row.\r
 **/\r
 VOID\r
-EFIAPI\r
 InputBarPrintInput (\r
   IN UINTN LastColumn,\r
   IN UINTN LastRow\r
@@ -103,7 +100,7 @@ InputBarPrintInput (
 \r
 typedef struct {\r
   UINT32  Foreground : 4;\r
-  UINT32  Background : 4;\r
+  UINT32  Background : 3;\r
 } INPUT_BAR_COLOR_ATTRIBUTES;\r
 \r
 typedef union {\r
@@ -121,7 +118,6 @@ typedef union {
   @retval EFI_SUCCESS           The operation was successful.\r
 **/\r
 EFI_STATUS\r
-EFIAPI\r
 InputBarRefresh (\r
   UINTN LastRow,\r
   UINTN LastColumn\r
@@ -133,8 +129,6 @@ InputBarRefresh (
   UINTN                   Size;\r
   EFI_STATUS              Status;\r
   BOOLEAN                 NoDisplay;\r
-  UINTN                   Limit;\r
-  UINTN                   mPromptLen;\r
   UINTN                   EventIndex;\r
   UINTN                   CursorRow;\r
   UINTN                   CursorCol;\r
@@ -151,10 +145,11 @@ InputBarRefresh (
   CursorCol             = gST->ConOut->Mode->CursorColumn;\r
   CursorRow             = gST->ConOut->Mode->CursorRow;\r
   Orig.Data             = gST->ConOut->Mode->Attribute;\r
-  New.Colors.Foreground = Orig.Colors.Background;\r
-  New.Colors.Background = Orig.Colors.Foreground;\r
+  New.Data              = 0;\r
+  New.Colors.Foreground = Orig.Colors.Background & 0xF;\r
+  New.Colors.Background = Orig.Colors.Foreground & 0x7;\r
 \r
-  gST->ConOut->SetAttribute (gST->ConOut, New.Data);\r
+  gST->ConOut->SetAttribute (gST->ConOut, New.Data & 0x7F);\r
 \r
   //\r
   // clear input bar\r
@@ -164,12 +159,6 @@ InputBarRefresh (
   gST->ConOut->SetCursorPosition (gST->ConOut, 0, LastRow - 1);\r
   ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN(STR_EDIT_LIBINPUTBAR_MAININPUTBAR), gShellDebug1HiiHandle, mPrompt);\r
 \r
-  //\r
-  // that's the maximum input length that can be displayed on screen\r
-  //\r
-  mPromptLen = StrLen (mPrompt);\r
-  Limit     = LastColumn - mPromptLen;\r
-\r
   //\r
   // this is a selection mPrompt, cursor will stay in edit area\r
   // actually this is for search , search/replace\r
@@ -268,7 +257,6 @@ InputBarRefresh (
   @retval EFI_OUT_OF_RESOURCES  A memory allocation failed.\r
 **/\r
 EFI_STATUS\r
-EFIAPI\r
 InputBarSetPrompt (\r
   IN CONST CHAR16 *Str\r
   )\r
@@ -295,7 +283,6 @@ InputBarSetPrompt (
   @retval EFI_OUT_OF_RESOURCES  A memory allocation failed.\r
 **/\r
 EFI_STATUS\r
-EFIAPI\r
 InputBarSetStringSize (\r
   UINTN   Size\r
   )\r
@@ -321,7 +308,6 @@ InputBarSetStringSize (
   @return The string that was input.\r
 **/\r
 CONST CHAR16*\r
-EFIAPI\r
 InputBarGetString (\r
   VOID\r
   )\r