From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-BN3-obe.outbound.protection.outlook.com (mail-bn3nam01on071c.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe41::71c]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 7F8FC1A1E0F for ; Thu, 6 Oct 2016 15:03:45 -0700 (PDT) Received: from CS1PR84MB0229.NAMPRD84.PROD.OUTLOOK.COM (10.162.190.151) by CS1PR84MB0230.NAMPRD84.PROD.OUTLOOK.COM (10.162.190.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.649.16; Thu, 6 Oct 2016 22:03:43 +0000 Received: from CS1PR84MB0229.NAMPRD84.PROD.OUTLOOK.COM ([10.162.190.151]) by CS1PR84MB0229.NAMPRD84.PROD.OUTLOOK.COM ([10.162.190.151]) with mapi id 15.01.0649.024; Thu, 6 Oct 2016 22:03:43 +0000 From: "Shah, Tapan" To: Vladimir Olovyannikov , "edk2-devel@lists.01.org" , "jaben.carsey@intel.com" Thread-Topic: [PATCH] ShellPkg: Fix erroneous Status returned by ShellOpenFileByName() Thread-Index: AQHSIB1dbX6Ied9XgkKhKMHHdb50o6Cb+qxA Date: Thu, 6 Oct 2016 22:03:43 +0000 Message-ID: References: <1475791346-17316-1-git-send-email-vladimir.olovyannikov@broadcom.com> In-Reply-To: <1475791346-17316-1-git-send-email-vladimir.olovyannikov@broadcom.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=tapandshah@hpe.com; x-originating-ip: [173.172.190.106] x-ms-office365-filtering-correlation-id: 23132c15-7162-4d72-782d-08d3ee34a356 x-microsoft-exchange-diagnostics: 1; CS1PR84MB0230; 7:s3ukyVSrb6nUfHJIdpSHBivB6WT2LNn8K5HgJ90MfKiir5vyE1O/s4ARXt15Zxdy+1lScQettoEJoacdPpArhU/nKBfuRJvMtuhUcmmhEFXhm+jh8RqFy36crgBEqerMEpXuFDF700l16BwvmmuJI3gBmCEThv8YDtZjP3gSN+yKCUK8deEMfKbhYZefxTTBlRsAGyosBvXUhsWLTrrk8yaWpi/e397naxjvcbJTeKzVII0FTdT6pxuvKd+bWkW+PL5iKnPf5mf0ZYdquwI1kQmlaGa9c6yK7G9u6OBfhJ/XWZ58V3Gd1pjj6/UPqIjOoqE1IOnG6MVRPFnz7bRjJA== x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CS1PR84MB0230; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(227479698468861)(162533806227266)(228905959029699); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6040176)(601004)(2401047)(5005006)(8121501046)(10201501046)(3002001)(6055026); SRVR:CS1PR84MB0230; BCL:0; PCL:0; RULEID:; SRVR:CS1PR84MB0230; x-forefront-prvs: 00872B689F x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(6009001)(6029001)(7916002)(199003)(377454003)(189002)(13464003)(99286002)(77096005)(81156014)(2501003)(81166006)(5001770100001)(2900100001)(106356001)(97736004)(3280700002)(305945005)(5660300001)(87936001)(8676002)(105586002)(10400500002)(74316002)(19580395003)(3660700001)(189998001)(106116001)(66066001)(33656002)(19580405001)(2950100002)(2906002)(107886002)(8936002)(92566002)(102836003)(11100500001)(5002640100001)(3846002)(6116002)(50986999)(586003)(7696004)(54356999)(76176999)(9686002)(86362001)(68736007)(7846002)(101416001)(122556002)(2201001)(7736002); DIR:OUT; SFP:1102; SCL:1; SRVR:CS1PR84MB0230; H:CS1PR84MB0229.NAMPRD84.PROD.OUTLOOK.COM; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; received-spf: None (protection.outlook.com: hpe.com does not designate permitted sender hosts) spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: hpe.com X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Oct 2016 22:03:43.3913 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 105b2061-b669-4b31-92ac-24d304d195dc X-MS-Exchange-Transport-CrossTenantHeadersStamped: CS1PR84MB0230 Subject: Re: [PATCH] ShellPkg: Fix erroneous Status returned by ShellOpenFileByName() X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Oct 2016 22:03:45 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Tapan Shah -----Original Message----- From: Vladimir Olovyannikov [mailto:vladimir.olovyannikov@broadcom.com]=20 Sent: Thursday, October 06, 2016 5:02 PM To: edk2-devel@lists.01.org; Shah, Tapan ; jaben.carsey= @intel.com Cc: Vladimir Olovyannikov Subject: [PATCH] ShellPkg: Fix erroneous Status returned by ShellOpenFileBy= Name() In ShellOpenFileByName() the file is opened using gEfiShellProtocol->OpenFileByName(). It is supposed that if this call returns an EFI_ERROR, the function should = return that error immediately. However, this return was missing, and if Uni= codeCollationProtocol has not been located by this time, the Status gets ov= erwritten with LocateProtocol() call result, which eventually erroneously r= eturns EFI_SUCCESS to the Shell.c, and this leads to attempt to execute a n= on-existent startup script, which fails, and which in turn leads to Shell b= eing unloaded with "Invalid parameter" error. This patch fixes the bug. Cc: Tapan Shah Cc: Jaben Carsey Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Vladimir Olovyannikov --- ShellPkg/Library/UefiShellLib/UefiShellLib.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ShellPkg/Library/UefiShellLib/UefiShellLib.c b/ShellPkg/Librar= y/UefiShellLib/UefiShellLib.c index 53f54e1746d4..8db18b3b210f 100644 --- a/ShellPkg/Library/UefiShellLib/UefiShellLib.c +++ b/ShellPkg/Library/UefiShellLib/UefiShellLib.c @@ -723,6 +723,9 @@ ShellOpenFileByName( Status =3D gEfiShellProtocol->OpenFileByName(FileName, FileHandle, OpenMode); + if (EFI_ERROR(Status)) { + return Status; + } =20 if (mUnicodeCollationProtocol =3D=3D NULL) { Status =3D gBS->LocateProtocol (&gEfiUnicodeCollation2ProtocolGuid, = NULL, (VOID**)&mUnicodeCollationProtocol); -- 1.9.1