public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH] ShellPkg: Fix a bug ">>v" cannot append data to environment variable
@ 2017-01-04  3:23 Ruiyu Ni
  2017-01-04 17:07 ` Carsey, Jaben
  0 siblings, 1 reply; 2+ messages in thread
From: Ruiyu Ni @ 2017-01-04  3:23 UTC (permalink / raw)
  To: edk2-devel; +Cc: chen881220, Chen A Chen, Jaben Carsey

From: chen881220 <ai_terran@foxmail.com>

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 <chen.a.chen@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Jaben Carsey <jaben.carsey@intel.com>
---
 ShellPkg/Application/Shell/FileHandleWrappers.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/ShellPkg/Application/Shell/FileHandleWrappers.c b/ShellPkg/Application/Shell/FileHandleWrappers.c
index 3c11d82..67ca8e7 100644
--- a/ShellPkg/Application/Shell/FileHandleWrappers.c
+++ b/ShellPkg/Application/Shell/FileHandleWrappers.c
@@ -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) {
-- 
2.9.0.windows.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-01-04 17:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-04  3:23 [PATCH] ShellPkg: Fix a bug ">>v" cannot append data to environment variable Ruiyu Ni
2017-01-04 17:07 ` Carsey, Jaben

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox