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.100; helo=mga07.intel.com; envelope-from=jaben.carsey@intel.com; receiver=edk2-devel@lists.01.org Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (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 7ADD921CEB149 for ; Wed, 25 Oct 2017 07:00:22 -0700 (PDT) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga105.jf.intel.com with ESMTP; 25 Oct 2017 07:04:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.43,431,1503385200"; d="scan'208";a="913612095" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by FMSMGA003.fm.intel.com with ESMTP; 25 Oct 2017 07:04:06 -0700 Received: from fmsmsx118.amr.corp.intel.com (10.18.116.18) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 25 Oct 2017 07:04:06 -0700 Received: from fmsmsx103.amr.corp.intel.com ([169.254.2.182]) by fmsmsx118.amr.corp.intel.com ([169.254.1.47]) with mapi id 14.03.0319.002; Wed, 25 Oct 2017 07:04:06 -0700 From: "Carsey, Jaben" To: "Ni, Ruiyu" , "edk2-devel@lists.01.org" CC: "Wu, Hao A" Thread-Topic: [PATCH] Shellpkg/editor: Fix a bug that may modifies Line[-1] Thread-Index: AQHTTS0KJHXLNZerXEWGsdmbm7CBIaL0mdwA Date: Wed, 25 Oct 2017 14:04:05 +0000 Message-ID: References: <20171025010308.53424-1-ruiyu.ni@intel.com> In-Reply-To: <20171025010308.53424-1-ruiyu.ni@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNDM4ZjBmMzYtYzNhZS00OWY1LTg0NGYtNmVlZmJlZTE1ODM0IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE2LjUuOS4zIiwiVHJ1c3RlZExhYmVsSGFzaCI6Ik92WFVnXC9vaHdkRCttRllDZFFWcG50aFhlT1dqck9nS0l4UDhDSndpdGpzPSJ9 x-ctpclassification: CTP_IC x-originating-ip: [10.1.200.106] 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: Wed, 25 Oct 2017 14:00:22 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Jaben Carsey > -----Original Message----- > From: Ni, Ruiyu > Sent: Tuesday, October 24, 2017 6:03 PM > To: edk2-devel@lists.01.org > Cc: Carsey, Jaben ; Wu, Hao A > > Subject: [PATCH] Shellpkg/editor: Fix a bug that may modifies Line[-1] > Importance: High >=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/UefiShellDebug1Comman > dsLib.c > b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1Comman > dsLib.c > index d26d08f95c..b45e9a33f3 100644 > --- > a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1Comman > dsLib.c > +++ > b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1Comman > dsLib.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