From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 629AF21A16E5F for ; Tue, 23 May 2017 08:51:06 -0700 (PDT) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 May 2017 08:51:06 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.38,382,1491289200"; d="scan'208";a="265440348" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by fmsmga004.fm.intel.com with ESMTP; 23 May 2017 08:51:05 -0700 Received: from fmsmsx119.amr.corp.intel.com (10.18.124.207) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 23 May 2017 08:51:05 -0700 Received: from fmsmsx103.amr.corp.intel.com ([169.254.2.204]) by FMSMSX119.amr.corp.intel.com ([169.254.14.10]) with mapi id 14.03.0319.002; Tue, 23 May 2017 08:51:05 -0700 From: "Carsey, Jaben" To: "Wu, Hao A" , "edk2-devel@lists.01.org" CC: "Ni, Ruiyu" Thread-Topic: [PATCH] ShellPkg/UefiShellLib: Avoid reading undefined content before string Thread-Index: AQHS02jndlfOZKIr/0SmrRGEHecdbaICEe6Q Date: Tue, 23 May 2017 15:51:05 +0000 Message-ID: References: <20170523020410.9184-1-hao.a.wu@intel.com> In-Reply-To: <20170523020410.9184-1-hao.a.wu@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNDA1N2Y5ZTQtZjdkNi00ODQ0LWExN2UtNTJjY2FiOWJlZGE1IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6InpSYjRJUzJhQXB4UzFSNmx3aDF3Vllkb3BFVExtOGdoQnpaVklNdXdaSzQ9In0= x-ctpclassification: CTP_IC x-originating-ip: [10.1.200.107] MIME-Version: 1.0 Subject: Re: [PATCH] ShellPkg/UefiShellLib: Avoid reading undefined content before string 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: Tue, 23 May 2017 15:51:06 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Jaben Carsey > -----Original Message----- > From: Wu, Hao A > Sent: Monday, May 22, 2017 7:04 PM > To: edk2-devel@lists.01.org > Cc: Wu, Hao A ; Ni, Ruiyu ; > Carsey, Jaben > Subject: [PATCH] ShellPkg/UefiShellLib: Avoid reading undefined content > before string > Importance: High >=20 > https://bugzilla.tianocore.org/show_bug.cgi?id=3D566 >=20 > In function InternalShellPrintWorker(), if the string in variable > 'mPostReplaceFormat2' starts with character L'%', the following > expression: >=20 > *(ResumeLocation-1) =3D=3D L'^' at line 2831 >=20 > will read an undefined value before the starting of string > 'mPostReplaceFormat2'. >=20 > This commit adds additional logic to avoid reading undefined content. >=20 > Cc: Ruiyu Ni > Cc: Jaben Carsey > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Hao Wu > --- > ShellPkg/Library/UefiShellLib/UefiShellLib.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) >=20 > diff --git a/ShellPkg/Library/UefiShellLib/UefiShellLib.c > b/ShellPkg/Library/UefiShellLib/UefiShellLib.c > index 55e8a67ac4..25706e9bc3 100644 > --- a/ShellPkg/Library/UefiShellLib/UefiShellLib.c > +++ b/ShellPkg/Library/UefiShellLib/UefiShellLib.c > @@ -2828,7 +2828,7 @@ InternalShellPrintWorker( > // update the attribute > // > if (ResumeLocation !=3D NULL) { > - if (*(ResumeLocation-1) =3D=3D L'^') { > + if ((ResumeLocation !=3D mPostReplaceFormat2) && (*(ResumeLocation= - > 1) =3D=3D L'^')) { > // > // Move cursor back 1 position to overwrite the ^ > // > -- > 2.12.0.windows.1