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.24; helo=mga09.intel.com; envelope-from=jaben.carsey@intel.com; receiver=edk2-devel@lists.01.org Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) (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 0E0AB2215BD96 for ; Mon, 5 Feb 2018 06:54:09 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Feb 2018 06:59:51 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,465,1511856000"; d="scan'208";a="15965773" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by orsmga006.jf.intel.com with ESMTP; 05 Feb 2018 06:59:51 -0800 Received: from fmsmsx120.amr.corp.intel.com (10.18.124.208) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 5 Feb 2018 06:59:51 -0800 Received: from fmsmsx103.amr.corp.intel.com ([169.254.2.47]) by fmsmsx120.amr.corp.intel.com ([169.254.15.251]) with mapi id 14.03.0319.002; Mon, 5 Feb 2018 06:59:50 -0800 From: "Carsey, Jaben" To: "Ni, Ruiyu" , "edk2-devel@lists.01.org" Thread-Topic: [PATCH] ShellPkg/for: Fix potential null pointer deference Thread-Index: AQHTnlZ6fOe3qK4NY0yRdG1v6KpnxaOV50DQ Date: Mon, 5 Feb 2018 14:59:50 +0000 Message-ID: References: <20180205075344.281956-1-ruiyu.ni@intel.com> In-Reply-To: <20180205075344.281956-1-ruiyu.ni@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiYjI0OTI3YjEtODdkNy00NzY3LWFhNzMtMzE1YTg2OWM2ZWU3IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE2LjUuOS4zIiwiVHJ1c3RlZExhYmVsSGFzaCI6InMxRVwvTCtxNzNYek0wRnFuRGFGaXF4S2FrZnhqZ0lqUGhvM2J5OXVvbzVzPSJ9 x-ctpclassification: CTP_NT x-originating-ip: [10.1.200.106] MIME-Version: 1.0 Subject: Re: [PATCH] ShellPkg/for: Fix potential null pointer deference X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 Feb 2018 14:54:10 -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: Sunday, February 04, 2018 11:54 PM > To: edk2-devel@lists.01.org > Cc: Carsey, Jaben > Subject: [PATCH] ShellPkg/for: Fix potential null pointer deference > Importance: High >=20 > When "FOR %a %a IN A B C" is executed, > CurrentScriptFile->CurrentCommand->Data is NULL. > But the code assumes it's not NULL and tries to > deference it. >=20 > The patch fixes this issue. >=20 > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Ruiyu Ni > Cc: Jaben Carsey > --- > ShellPkg/Library/UefiShellLevel1CommandsLib/For.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) >=20 > diff --git a/ShellPkg/Library/UefiShellLevel1CommandsLib/For.c > b/ShellPkg/Library/UefiShellLevel1CommandsLib/For.c > index 3db4bb58d3..9824977149 100644 > --- a/ShellPkg/Library/UefiShellLevel1CommandsLib/For.c > +++ b/ShellPkg/Library/UefiShellLevel1CommandsLib/For.c > @@ -2,7 +2,7 @@ > Main file for endfor and for shell level 1 functions. >=20 > (C) Copyright 2015 Hewlett-Packard Development Company, L.P.
> - Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
> + Copyright (c) 2009 - 2018, 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 > @@ -624,7 +624,9 @@ ShellCommandRunFor ( > if (CurrentScriptFile !=3D NULL && CurrentScriptFile->CurrentCommand != =3D > NULL) { > Info =3D (SHELL_FOR_INFO*)CurrentScriptFile->CurrentCommand->Data; > if (CurrentScriptFile->CurrentCommand->Reset) { > - Info->CurrentValue =3D (CHAR16*)Info->Set; > + if (Info !=3D NULL) { > + Info->CurrentValue =3D (CHAR16*)Info->Set; > + } > FirstPass =3D TRUE; > CurrentScriptFile->CurrentCommand->Reset =3D FALSE; > } > -- > 2.16.1.windows.1