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=liming.gao@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 A65F7211CAF39 for ; Wed, 20 Feb 2019 06:27:43 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Feb 2019 06:27:42 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,391,1544515200"; d="scan'208";a="145815825" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by fmsmga004.fm.intel.com with ESMTP; 20 Feb 2019 06:27:42 -0800 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.408.0; Wed, 20 Feb 2019 06:27:41 -0800 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.102]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.109]) with mapi id 14.03.0415.000; Wed, 20 Feb 2019 22:27:36 +0800 From: "Gao, Liming" To: "Gao, Zhichao" , "edk2-devel@lists.01.org" Thread-Topic: [PATCH] ShellPkg: add array index check for shell delay option Thread-Index: AQHUx2PyA8KdIGpPRUKAx4btr5HYFaXowgrw Date: Wed, 20 Feb 2019 14:27:35 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14E3E2A78@SHSMSX104.ccr.corp.intel.com> References: <20190218082809.6432-1-zhichao.gao@intel.com> In-Reply-To: <20190218082809.6432-1-zhichao.gao@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ctpclassification: CTP_NT x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMTczYzFhNTYtZGQyYS00MjdmLWJjNDUtNGVhNjZlY2M5N2NkIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiK0krbFJ6MkM2a05oS2ZtYmxoSVRZOGV4NjFkOHVXckNlb3BSemdSTWdYOVVLV2g1MjhVUEhkMHJwVGk2cEVkOSJ9 dlp-product: dlpe-windows dlp-version: 11.0.400.15 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH] ShellPkg: add array index check for shell delay option X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Feb 2019 14:27:43 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Liming Gao > -----Original Message----- > From: Gao, Zhichao > Sent: Monday, February 18, 2019 4:28 PM > To: edk2-devel@lists.01.org > Cc: Gao, Liming ; Ni, Ray > Subject: [PATCH] ShellPkg: add array index check for shell delay option >=20 > BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1528 >=20 > Shell delay option without parameters do not check the > index of shell parameter argv. Add index check to avoid > invalid pointer references. >=20 > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Zhichao Gao >=20 > Cc: Liming Gao > Cc: Ray Ni > --- > ShellPkg/Application/Shell/Shell.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) >=20 > diff --git a/ShellPkg/Application/Shell/Shell.c b/ShellPkg/Application/Sh= ell/Shell.c > index 104f4c8961..ec344137d3 100644 > --- a/ShellPkg/Application/Shell/Shell.c > +++ b/ShellPkg/Application/Shell/Shell.c > @@ -1,7 +1,7 @@ > /** @file > This is THE shell (application) >=20 > - Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.
> + Copyright (c) 2009 - 2019, Intel Corporation. All rights reserved.
> (C) Copyright 2013-2014 Hewlett-Packard Development Company, L.P.
> Copyright 2015-2018 Dell Technologies.
> This program and the accompanying materials > @@ -1002,7 +1002,11 @@ ProcessCommandLine( > ) =3D=3D 0) { > ShellInfoObject.ShellInitSettings.BitUnion.Bits.Delay =3D T= RUE; > // Check for optional delay value following "-delay" > - DelayValueStr =3D gEfiShellParametersProtocol->Argv[LoopVar + 1]; > + if ((LoopVar + 1) >=3D gEfiShellParametersProtocol->Argc) { > + DelayValueStr =3D NULL; > + } else { > + DelayValueStr =3D gEfiShellParametersProtocol->Argv[LoopVar + 1]= ; > + } > if (DelayValueStr !=3D NULL){ > if (*DelayValueStr =3D=3D L':') { > DelayValueStr++; > -- > 2.16.2.windows.1