From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.65; helo=mga03.intel.com; envelope-from=hao.a.wu@intel.com; receiver=edk2-devel@lists.01.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (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 426F22034A7B8 for ; Wed, 25 Oct 2017 18:34:44 -0700 (PDT) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Oct 2017 18:38:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.43,433,1503385200"; d="scan'208";a="913829967" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by FMSMGA003.fm.intel.com with ESMTP; 25 Oct 2017 18:38:29 -0700 Received: from fmsmsx151.amr.corp.intel.com (10.18.125.4) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 25 Oct 2017 18:38:29 -0700 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by FMSMSX151.amr.corp.intel.com (10.18.125.4) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 25 Oct 2017 18:38:22 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.152]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.218]) with mapi id 14.03.0319.002; Thu, 26 Oct 2017 09:38:20 +0800 From: "Wu, Hao A" To: "Ni, Ruiyu" , "edk2-devel@lists.01.org" CC: "Carsey, Jaben" Thread-Topic: [PATCH] Shellpkg/editor: Fix a bug that may modifies Line[-1] Thread-Index: AQHTTS0M1tpagK4SZUOhhsvZiSkCsaL1W8pA Date: Thu, 26 Oct 2017 01:38:19 +0000 Message-ID: References: <20171025010308.53424-1-ruiyu.ni@intel.com> In-Reply-To: <20171025010308.53424-1-ruiyu.ni@intel.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [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: Thu, 26 Oct 2017 01:34:44 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Hao Wu Best Regards, Hao Wu > -----Original Message----- > From: Ni, Ruiyu > Sent: Wednesday, October 25, 2017 9:03 AM > To: edk2-devel@lists.01.org > Cc: Carsey, Jaben; Wu, Hao A > Subject: [PATCH] Shellpkg/editor: Fix a bug that may modifies Line[-1] >=20 > The original code as below intend to set the character > before last column to CHAR_NULL. > Line[(LastCol % (ARRAY_SIZE (Line) - 1)) - 1] =3D CHAR_NULL; >=20 > But when LastCol % (ARRAY_SIZE (Line) - 1)) equals to 0, > Line[-1] is modified. >=20 > We should change to code as below: > Line[(LastCol - 1) % (ARRAY_SIZE (Line) - 1)] =3D CHAR_NULL; >=20 > 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(-) >=20 > diff --git > a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1Commands > Lib.c > b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1Commands > Lib.c > index d26d08f95c..b45e9a33f3 100644 > --- > a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1Commands > Lib.c > +++ > b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1Commands > Lib.c > @@ -205,7 +205,7 @@ EditorClearLine ( > // > // if CHAR_NULL is still at position LastCol, it will cause firs= t line error > // > - Line[(LastCol % (ARRAY_SIZE (Line) - 1)) - 1] =3D CHAR_NULL; > + Line[(LastCol - 1) % (ARRAY_SIZE (Line) - 1)] =3D CHAR_NULL; > } else { > Line[LastCol % (ARRAY_SIZE (Line) - 1)] =3D CHAR_NULL; > } > -- > 2.12.2.windows.2