From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.93; helo=mga11.intel.com; envelope-from=ruiyu.ni@intel.com; receiver=edk2-devel@lists.01.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (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 20387210D97B2 for ; Tue, 7 Aug 2018 02:13:42 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Aug 2018 02:13:41 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,454,1526367600"; d="scan'208";a="64140177" Received: from ray-dev.ccr.corp.intel.com ([10.239.9.4]) by orsmga006.jf.intel.com with ESMTP; 07 Aug 2018 02:13:28 -0700 From: Ruiyu Ni To: edk2-devel@lists.01.org Cc: Jaben Carsey , Jim Dailey Date: Tue, 7 Aug 2018 17:14:01 +0800 Message-Id: <20180807091401.48840-1-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.16.1.windows.1 Subject: [PATCH] ShellPkg/set: Fix EfiShellSetEnv to use case sensitive compare X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 07 Aug 2018 09:13:43 -0000 REF: https://bugzilla.tianocore.org/show_bug.cgi?id=777 Per Shell spec, the environment variable has a case-sensitive name. But today's implementation of EfiShellSetEnv() compares the environment variable name case insensitively, which causes variable like "CWD" cannot be set due to "cwd" is pre-defined variable. The patch fixes this issue. The EfiShellGetEnv() doesn't have such issue because it will call into ShellFindEnvVarInList() which uses StrCmp(). Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni Cc: Jaben Carsey Cc: Jim Dailey --- ShellPkg/Application/Shell/ShellProtocol.c | 39 +++++++----------------------- 1 file changed, 9 insertions(+), 30 deletions(-) diff --git a/ShellPkg/Application/Shell/ShellProtocol.c b/ShellPkg/Application/Shell/ShellProtocol.c index f2ca2029e3..767cbc99a0 100644 --- a/ShellPkg/Application/Shell/ShellProtocol.c +++ b/ShellPkg/Application/Shell/ShellProtocol.c @@ -2924,36 +2924,15 @@ EfiShellSetEnv( // // Make sure we dont 'set' a predefined read only variable // - if (gUnicodeCollation->StriColl( - gUnicodeCollation, - (CHAR16*)Name, - L"cwd") == 0 - ||gUnicodeCollation->StriColl( - gUnicodeCollation, - (CHAR16*)Name, - L"Lasterror") == 0 - ||gUnicodeCollation->StriColl( - gUnicodeCollation, - (CHAR16*)Name, - L"profiles") == 0 - ||gUnicodeCollation->StriColl( - gUnicodeCollation, - (CHAR16*)Name, - L"uefishellsupport") == 0 - ||gUnicodeCollation->StriColl( - gUnicodeCollation, - (CHAR16*)Name, - L"uefishellversion") == 0 - ||gUnicodeCollation->StriColl( - gUnicodeCollation, - (CHAR16*)Name, - L"uefiversion") == 0 - ||(!ShellInfoObject.ShellInitSettings.BitUnion.Bits.NoNest && - gUnicodeCollation->StriColl( - gUnicodeCollation, - (CHAR16*)Name, - (CHAR16*)mNoNestingEnvVarName) == 0) - ){ + if ((StrCmp (Name, L"cwd") == 0) || + (StrCmp (Name, L"Lasterror") == 0) || + (StrCmp (Name, L"profiles") == 0) || + (StrCmp (Name, L"uefishellsupport") == 0) || + (StrCmp (Name, L"uefishellversion") == 0) || + (StrCmp (Name, L"uefiversion") == 0) || + (!ShellInfoObject.ShellInitSettings.BitUnion.Bits.NoNest && + StrCmp (Name, mNoNestingEnvVarName) == 0) + ) { return (EFI_INVALID_PARAMETER); } return (InternalEfiShellSetEnv(Name, Value, Volatile)); -- 2.16.1.windows.1