From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.120; helo=mga04.intel.com; envelope-from=ruiyu.ni@intel.com; receiver=edk2-devel@lists.01.org Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (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 D42F620347143 for ; Tue, 24 Oct 2017 17:59:29 -0700 (PDT) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 Oct 2017 18:03:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.43,430,1503385200"; d="scan'208";a="167188394" Received: from ray-dev.ccr.corp.intel.com ([10.239.9.7]) by fmsmga006.fm.intel.com with ESMTP; 24 Oct 2017 18:03:12 -0700 From: Ruiyu Ni To: edk2-devel@lists.01.org Cc: Jaben Carsey , Hao A Wu Date: Wed, 25 Oct 2017 09:03:08 +0800 Message-Id: <20171025010308.53424-1-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.12.2.windows.2 Subject: [PATCH] Shellpkg/editor: Fix a bug that may modifies Line[-1] X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Oct 2017 00:59:30 -0000 The original code as below intend to set the character before last column to CHAR_NULL. Line[(LastCol % (ARRAY_SIZE (Line) - 1)) - 1] = CHAR_NULL; But when LastCol % (ARRAY_SIZE (Line) - 1)) equals to 0, Line[-1] is modified. We should change to code as below: Line[(LastCol - 1) % (ARRAY_SIZE (Line) - 1)] = CHAR_NULL; Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni Cc: Jaben Carsey Cc: Hao A Wu --- .../Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.c index d26d08f95c..b45e9a33f3 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.c +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.c @@ -205,7 +205,7 @@ EditorClearLine ( // // if CHAR_NULL is still at position LastCol, it will cause first line error // - Line[(LastCol % (ARRAY_SIZE (Line) - 1)) - 1] = CHAR_NULL; + Line[(LastCol - 1) % (ARRAY_SIZE (Line) - 1)] = CHAR_NULL; } else { Line[LastCol % (ARRAY_SIZE (Line) - 1)] = CHAR_NULL; } -- 2.12.2.windows.2