From nobody Tue May 13 14:01:58 2025 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 1533786271534534.8528191450134; Wed, 8 Aug 2018 20:44:31 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 0BDB8210E38B7; Wed, 8 Aug 2018 20:44:29 -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 D0D12210E38B1 for ; Wed, 8 Aug 2018 20:44:27 -0700 (PDT) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Aug 2018 20:44:28 -0700 Received: from ray-dev.ccr.corp.intel.com ([10.239.9.4]) by orsmga001.jf.intel.com with ESMTP; 08 Aug 2018 20:44:26 -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.53,213,1531810800"; d="scan'208";a="80168745" From: Ruiyu Ni To: edk2-devel@lists.01.org Date: Thu, 9 Aug 2018 11:45:02 +0800 Message-Id: <20180809034502.131768-3-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.16.1.windows.1 In-Reply-To: <20180809034502.131768-1-ruiyu.ni@intel.com> References: <20180809034502.131768-1-ruiyu.ni@intel.com> Subject: [edk2] [PATCH 2/2] ShellPkg/redirection: Insert \xFEFF for ENV variable redirection 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 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=3D1080 Per Shell spec 2.2 chapter 3.4.4.2, Unicode file tag should be inserted in the output from the input redirected variable, to ensure it looks like a UCS-2 encode file. The patch fixes this issue. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni Cc: Jaben Carsey --- ShellPkg/Application/Shell/FileHandleWrappers.c | 34 ++++++++++++++++++++-= ---- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/ShellPkg/Application/Shell/FileHandleWrappers.c b/ShellPkg/App= lication/Shell/FileHandleWrappers.c index 655854b25d..bcce055321 100644 --- a/ShellPkg/Application/Shell/FileHandleWrappers.c +++ b/ShellPkg/Application/Shell/FileHandleWrappers.c @@ -1148,15 +1148,35 @@ FileInterfaceEnvDelete( EFI_STATUS EFIAPI FileInterfaceEnvRead( - IN EFI_FILE_PROTOCOL *This, - IN OUT UINTN *BufferSize, - OUT VOID *Buffer + IN EFI_FILE_PROTOCOL *This, + IN OUT UINTN *BufferSize, + OUT VOID *Buffer ) { - return (SHELL_GET_ENVIRONMENT_VARIABLE( - ((EFI_FILE_PROTOCOL_ENVIRONMENT*)This)->Name, - BufferSize, - Buffer)); + EFI_STATUS Status; + + *BufferSize =3D *BufferSize / sizeof (CHAR16) * sizeof (CHAR16); + if (*BufferSize !=3D 0) { + // + // Make sure the first unicode character is \xFEFF + // + *(CHAR16 *)Buffer =3D gUnicodeFileTag; + Buffer =3D (CHAR16 *)Buffer + 1; + *BufferSize -=3D sizeof (gUnicodeFileTag); + } + + Status =3D SHELL_GET_ENVIRONMENT_VARIABLE ( + ((EFI_FILE_PROTOCOL_ENVIRONMENT*)This)->Name, + BufferSize, + Buffer + ); + if (!EFI_ERROR (Status) || (Status =3D=3D EFI_BUFFER_TOO_SMALL)) { + // + // BufferSize is valid and needs update when Status is Success or Buff= erTooSmall. + // + *BufferSize +=3D sizeof (gUnicodeFileTag); + } + return Status; } =20 /** --=20 2.16.1.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel