From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 2AAC68204C for ; Thu, 9 Feb 2017 18:27:19 -0800 (PST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga101.fm.intel.com with ESMTP; 09 Feb 2017 18:27:18 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.35,138,1484035200"; d="scan'208";a="42315070" Received: from shwdeopenpsi114.ccr.corp.intel.com ([10.239.157.135]) by orsmga002.jf.intel.com with ESMTP; 09 Feb 2017 18:27:17 -0800 From: Dandan Bi To: edk2-devel@lists.01.org Cc: Eric Dong , Liming Gao , Wang Cloud Date: Fri, 10 Feb 2017 10:25:30 +0800 Message-Id: <1486693530-222908-1-git-send-email-dandan.bi@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.1 Subject: [patch] MdeMoudlePkg/DisplayEngine: Fix incorrect index used in array "InputText" X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 Feb 2017 02:27:19 -0000 When set value to the array "InputText", the index was used incorrectly. And the array "InputText" is not initialized. These will cause some value in the array is random, so it will be shown incorrectly sometimes. This patch is to fix this issue. https://bugzilla.tianocore.org/show_bug.cgi?id=358 Cc: Eric Dong Cc: Liming Gao Cc: Wang Cloud Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Dandan Bi --- .../Universal/DisplayEngineDxe/InputHandler.c | 33 ++++++++++++---------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/MdeModulePkg/Universal/DisplayEngineDxe/InputHandler.c b/MdeModulePkg/Universal/DisplayEngineDxe/InputHandler.c index 400b934..d02c0bf 100644 --- a/MdeModulePkg/Universal/DisplayEngineDxe/InputHandler.c +++ b/MdeModulePkg/Universal/DisplayEngineDxe/InputHandler.c @@ -1,9 +1,9 @@ /** @file Implementation for handling user input from the User Interfaces. -Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2017, 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 http://opensource.org/licenses/bsd-license.php @@ -522,10 +522,11 @@ GetNumericInput ( Negative = FALSE; ValidateFail = FALSE; Question = MenuOption->ThisTag; QuestionValue = &Question->CurrentValue; + ZeroMem (InputText, MAX_NUMERIC_INPUT_WIDTH * sizeof (CHAR16)); // // Only two case, user can enter to this function: Enter and +/- case. // In Enter case, gDirection = 0; in +/- case, gDirection = SCAN_LEFT/SCAN_WRIGHT // @@ -688,20 +689,21 @@ GetNumericInput ( } if (MenuOption->Sequence == 0) { InputText[0] = LEFT_NUMERIC_DELIMITER; SetUnicodeMem (InputText + 1, InputWidth, L' '); - } else { + InputText[InputWidth + 1] = DATE_SEPARATOR; + InputText[InputWidth + 2] = L'\0'; + } else if (MenuOption->Sequence == 1){ SetUnicodeMem (InputText, InputWidth, L' '); - } - - if (MenuOption->Sequence == 2) { - InputText[InputWidth + 1] = RIGHT_NUMERIC_DELIMITER; + InputText[InputWidth] = DATE_SEPARATOR; + InputText[InputWidth + 1] = L'\0'; } else { - InputText[InputWidth + 1] = DATE_SEPARATOR; + SetUnicodeMem (InputText, InputWidth, L' '); + InputText[InputWidth] = RIGHT_NUMERIC_DELIMITER; + InputText[InputWidth + 1] = L'\0'; } - InputText[InputWidth + 2] = L'\0'; PrintStringAt (Column, Row, InputText); if (MenuOption->Sequence == 0) { Column++; } @@ -711,20 +713,21 @@ GetNumericInput ( InputWidth = 2; if (MenuOption->Sequence == 0) { InputText[0] = LEFT_NUMERIC_DELIMITER; SetUnicodeMem (InputText + 1, InputWidth, L' '); - } else { + InputText[InputWidth + 1] = TIME_SEPARATOR; + InputText[InputWidth + 2] = L'\0'; + } else if (MenuOption->Sequence == 1){ SetUnicodeMem (InputText, InputWidth, L' '); - } - - if (MenuOption->Sequence == 2) { - InputText[InputWidth + 1] = RIGHT_NUMERIC_DELIMITER; + InputText[InputWidth] = TIME_SEPARATOR; + InputText[InputWidth + 1] = L'\0'; } else { - InputText[InputWidth + 1] = TIME_SEPARATOR; + SetUnicodeMem (InputText, InputWidth, L' '); + InputText[InputWidth] = RIGHT_NUMERIC_DELIMITER; + InputText[InputWidth + 1] = L'\0'; } - InputText[InputWidth + 2] = L'\0'; PrintStringAt (Column, Row, InputText); if (MenuOption->Sequence == 0) { Column++; } -- 1.9.5.msysgit.1