From nobody Fri Apr 19 15:31:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail(p=none dis=none) header.from=intel.com Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1533633225770852.3824790315294; Tue, 7 Aug 2018 02:13:45 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 95097210DC1B7; Tue, 7 Aug 2018 02:13:44 -0700 (PDT) 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) 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 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 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; 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 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,454,1526367600"; d="scan'208";a="64140177" From: Ruiyu Ni To: edk2-devel@lists.01.org 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: [edk2] [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: , Cc: Jaben Carsey , Jim Dailey MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RDMRC_1 RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D777 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 Reviewed-by: Jaben Carsey --- ShellPkg/Application/Shell/ShellProtocol.c | 39 +++++++-------------------= ---- 1 file changed, 9 insertions(+), 30 deletions(-) diff --git a/ShellPkg/Application/Shell/ShellProtocol.c b/ShellPkg/Applicat= ion/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") =3D=3D 0 - ||gUnicodeCollation->StriColl( - gUnicodeCollation, - (CHAR16*)Name, - L"Lasterror") =3D=3D 0 - ||gUnicodeCollation->StriColl( - gUnicodeCollation, - (CHAR16*)Name, - L"profiles") =3D=3D 0 - ||gUnicodeCollation->StriColl( - gUnicodeCollation, - (CHAR16*)Name, - L"uefishellsupport") =3D=3D 0 - ||gUnicodeCollation->StriColl( - gUnicodeCollation, - (CHAR16*)Name, - L"uefishellversion") =3D=3D 0 - ||gUnicodeCollation->StriColl( - gUnicodeCollation, - (CHAR16*)Name, - L"uefiversion") =3D=3D 0 - ||(!ShellInfoObject.ShellInitSettings.BitUnion.Bits.NoNest && - gUnicodeCollation->StriColl( - gUnicodeCollation, - (CHAR16*)Name, - (CHAR16*)mNoNestingEnvVarName) =3D=3D 0) - ){ + if ((StrCmp (Name, L"cwd") =3D=3D 0) || + (StrCmp (Name, L"Lasterror") =3D=3D 0) || + (StrCmp (Name, L"profiles") =3D=3D 0) || + (StrCmp (Name, L"uefishellsupport") =3D=3D 0) || + (StrCmp (Name, L"uefishellversion") =3D=3D 0) || + (StrCmp (Name, L"uefiversion") =3D=3D 0) || + (!ShellInfoObject.ShellInitSettings.BitUnion.Bits.NoNest && + StrCmp (Name, mNoNestingEnvVarName) =3D=3D 0) + ) { return (EFI_INVALID_PARAMETER); } return (InternalEfiShellSetEnv(Name, Value, Volatile)); --=20 2.16.1.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel