From: Jaben Carsey Date: Mon, 13 Jan 2014 18:52:48 +0000 (+0000) Subject: ShellPkg: Remove UNICODE file tag (FEFF) from files used for input redirection X-Git-Tag: edk2-stable201903~11848 X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=49bb76ff717a8a02e23ef0585b142e5117fbaee1;p=mirror_edk2.git ShellPkg: Remove UNICODE file tag (FEFF) from files used for input redirection Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jaben Carsey Reviewed-by: Erik Bjorge git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15109 6f19259b-4bc3-4df7-8a09-765794883524 --- diff --git a/ShellPkg/Application/Shell/ShellParametersProtocol.c b/ShellPkg/Application/Shell/ShellParametersProtocol.c index 9b385bee15..ab435a1263 100644 --- a/ShellPkg/Application/Shell/ShellParametersProtocol.c +++ b/ShellPkg/Application/Shell/ShellParametersProtocol.c @@ -3,7 +3,7 @@ manipulation, and initialization of EFI_SHELL_PARAMETERS_PROTOCOL. Copyright (c) 2013 Hewlett-Packard Development Company, L.P. - Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved.
+ Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -567,6 +567,28 @@ FixVarName ( return (FixFileName(Copy)); } +/** + Remove the unicode file tag from the begining of the file buffer since that will not be + used by StdIn. +**/ +EFI_STATUS +EFIAPI +RemoveFileTag( + IN SHELL_FILE_HANDLE *Handle + ) +{ + UINTN CharSize; + CHAR16 CharBuffer; + + CharSize = sizeof(CHAR16); + CharBuffer = 0; + gEfiShellProtocol->ReadFile(*Handle, &CharSize, &CharBuffer); + if (CharBuffer != gUnicodeFileTag) { + gEfiShellProtocol->SetFilePosition(*Handle, 0); + } + return (EFI_SUCCESS); +} + /** Funcion will replace the current StdIn and StdOut in the ShellParameters protocol structure by parsing NewCommandLine. The current values are returned to the @@ -1148,7 +1170,15 @@ UpdateStdInStdOutStdErr( &TempHandle, EFI_FILE_MODE_READ, 0); - if (!InUnicode && !EFI_ERROR(Status)) { + if (InUnicode) { + // + // Chop off the 0xFEFF if it's there... + // + RemoveFileTag(&TempHandle); + } else if (!EFI_ERROR(Status)) { + // + // Create the ASCII->Unicode conversion layer + // TempHandle = CreateFileInterfaceFile(TempHandle, FALSE); } if (!EFI_ERROR(Status)) {