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.126; helo=mga18.intel.com; envelope-from=jaben.carsey@intel.com; receiver=edk2-devel@lists.01.org Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) (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 ADF5B21BADAB9 for ; Tue, 7 Aug 2018 10:57:21 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Aug 2018 10:57:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,456,1526367600"; d="scan'208";a="63049125" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by orsmga007.jf.intel.com with ESMTP; 07 Aug 2018 10:57:20 -0700 Received: from fmsmsx112.amr.corp.intel.com (10.18.116.6) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 7 Aug 2018 10:57:20 -0700 Received: from fmsmsx103.amr.corp.intel.com ([169.254.2.126]) by FMSMSX112.amr.corp.intel.com ([169.254.5.84]) with mapi id 14.03.0319.002; Tue, 7 Aug 2018 10:57:20 -0700 From: "Carsey, Jaben" To: "Ni, Ruiyu" , "edk2-devel@lists.01.org" CC: Jim Dailey Thread-Topic: [PATCH] ShellPkg/set: Fix EfiShellSetEnv to use case sensitive compare Thread-Index: AQHULi8CauDrpksFZ0uvoU/8vPYecKS0k8kg Date: Tue, 7 Aug 2018 17:57:20 +0000 Message-ID: References: <20180807091401.48840-1-ruiyu.ni@intel.com> In-Reply-To: <20180807091401.48840-1-ruiyu.ni@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMmQ3ZjUzYWItNTZmMC00NjRmLTkzZjktOWMzYzliZDY4NTg4IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiSUI4UytnR0lQXC9yV3VOQ0dtck94NTBVU2JcL0F6UG5IVExqdXNIQXZVVlFqUkdncmVNVXVxM0dYc2s3RDZEWjFuIn0= x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.400.15 dlp-reaction: no-action x-originating-ip: [10.1.200.107] MIME-Version: 1.0 Subject: Re: [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 17:57:21 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Jaben Carsey > -----Original Message----- > From: Ni, Ruiyu > Sent: Tuesday, August 07, 2018 2:14 AM > To: edk2-devel@lists.01.org > Cc: Carsey, Jaben ; Jim Dailey > > Subject: [PATCH] ShellPkg/set: Fix EfiShellSetEnv to use case sensitive > compare > Importance: High >=20 > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D777 >=20 > 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. >=20 > The patch fixes this issue. >=20 > The EfiShellGetEnv() doesn't have such issue because it will > call into ShellFindEnvVarInList() which uses StrCmp(). >=20 > 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(-) >=20 > 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") =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)); > -- > 2.16.1.windows.1