From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf0-x22f.google.com (mail-pf0-x22f.google.com [IPv6:2607:f8b0:400e:c00::22f]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 05AF21A1DFF for ; Thu, 6 Oct 2016 14:40:06 -0700 (PDT) Received: by mail-pf0-x22f.google.com with SMTP id 190so14831221pfv.0 for ; Thu, 06 Oct 2016 14:40:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id; bh=MNNr2r3ysUf+l/MifSKSjA7gP9WWmqLZ2MUmgiWGBoU=; b=FzUtpJaPCbfGXudEPgliWMOofN3HdfXkpMZoX1dQmZbgfPEZiTCt85JbhJbKwqNm8D 8Bj6r7TxY1V8GgC/n4lcQzGKwN3URviBF6l3U2KQUPamI1ZEvFS6g2TRLk2jCTEIGORU 5c8xoSAXxLXaNFpYccwNLTw8NB+7YP7LvqCy8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=MNNr2r3ysUf+l/MifSKSjA7gP9WWmqLZ2MUmgiWGBoU=; b=FOxXobr5/w6BAtI+b/35y2UOu3sePeIAGIoSFR2MwARwh70Co995a+lAjaMlhI2PzY dhOYmM2aj1qdG5roveh/7CxFx/K/LW6bgfT4ArH5NxDxlwu2ZUr1utTnaMlfxD3eE0ZH bu9V1/mBvTG0/pRWvxj5pXe7yzpLEQsr1J/CaJdwOYpwCM5Rn+jWIqyD+lGYxj68DHRs oTfuD2WpMpWLceWu7zgNrO3VKZIhvtcmwaOWGJu4yPNXASX81rJP9DXUWiWM7OT89dUq PKqCY45LeGQ5MZOIQKT3Q6u7ajLqshQfWArkxOGJGsSAaX1oOCyWUPDlUs2UHFwTRNtl HZPQ== X-Gm-Message-State: AA6/9RkVxvJZP3RchmTEch2dLybi8e0ARDdVqy0lRipLq3zUNxLlWVFaKOpVOnYlGIBvniIn X-Received: by 10.98.35.84 with SMTP id j81mr21186998pfj.166.1475790005394; Thu, 06 Oct 2016 14:40:05 -0700 (PDT) Received: from LBRMN-LNXUB114.ric.broadcom.com ([216.31.219.19]) by smtp.gmail.com with ESMTPSA id n88sm8142374pfk.56.2016.10.06.14.40.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 06 Oct 2016 14:40:05 -0700 (PDT) From: Vladimir Olovyannikov To: edk2-devel@lists.01.org, tapandshah@hpe.com, jaben.carsey@intel.com Cc: Vladimir Olovyannikov , Vladimir Olovyannikov Date: Thu, 6 Oct 2016 14:40:07 -0700 Message-Id: <1475790007-16365-1-git-send-email-vladimir.olovyannikov@broadcom.com> X-Mailer: git-send-email 1.9.1 Subject: [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 21:40:06 -0000 From: Vladimir Olovyannikov 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 UnicodeCollationProtocol has not been located by this time, the Status gets overwritten with LocateProtocol() call result, which eventually erroneously returns EFI_SUCCESS to the Shell.c, and this leads to attempt to execute a non-existent startup script, which fails, and which in turn leads to Shell being 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 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ShellPkg/Library/UefiShellLib/UefiShellLib.c b/ShellPkg/Library/UefiShellLib/UefiShellLib.c index 53f54e1746d4..6fa67a3e751c 100644 --- a/ShellPkg/Library/UefiShellLib/UefiShellLib.c +++ b/ShellPkg/Library/UefiShellLib/UefiShellLib.c @@ -723,6 +723,8 @@ ShellOpenFileByName( Status = gEfiShellProtocol->OpenFileByName(FileName, FileHandle, OpenMode); + if (EFI_ERROR(Status)) { + return Status; if (mUnicodeCollationProtocol == NULL) { Status = gBS->LocateProtocol (&gEfiUnicodeCollation2ProtocolGuid, NULL, (VOID**)&mUnicodeCollationProtocol); -- 1.9.1