From 5016d46603addf62656590e83375074abc321f23 Mon Sep 17 00:00:00 2001 From: Chen A Chen Date: Wed, 4 Jan 2017 11:28:03 +0800 Subject: ShellPkg: Fix a bug ">>v" cannot append data to environment variable When ">v" is used to redirect the command output to environment variable, the ending "\r\n\0" is removed before setting to environment variable but the length is not updated. It causes ">>v" fails to append data to the environment variable created by ">v". The patch fixes the above bug. Signed-off-by: Chen A Chen Reviewed-by: Ruiyu Ni Reviewed-by: Jaben Carsey --- ShellPkg/Application/Shell/FileHandleWrappers.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ShellPkg/Application/Shell/FileHandleWrappers.c b/ShellPkg/Application/Shell/FileHandleWrappers.c index 3c11d82944..0a7a60294d 100644 --- a/ShellPkg/Application/Shell/FileHandleWrappers.c +++ b/ShellPkg/Application/Shell/FileHandleWrappers.c @@ -3,7 +3,7 @@ StdIn, StdOut, StdErr, etc...). Copyright 2016 Dell Inc. - Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
+ Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.
(C) Copyright 2013 Hewlett-Packard Development Company, L.P.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License @@ -1074,6 +1074,10 @@ FileInterfaceEnvClose( (((CHAR16*)NewBuffer)[TotalSize / sizeof (CHAR16) - 3] == CHAR_CARRIAGE_RETURN) ) { ((CHAR16*)NewBuffer)[TotalSize / sizeof (CHAR16) - 3] = CHAR_NULL; + // + // If the NewBuffer end with \r\n\0, We will repace '\r' by '\0' and then update TotalSize. + // + TotalSize -= sizeof(CHAR16) * 2; } if (Volatile) { -- cgit v1.2.3