]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Application/Shell/FileHandleWrappers.c
ShellPkg: Fix a bug ">>v" cannot append data to environment variable
[mirror_edk2.git] / ShellPkg / Application / Shell / FileHandleWrappers.c
index 3c11d82944e792ab0fda2474f1b2dbf22940e4dc..0a7a60294dc79d7171d17eb85c2748d45be043c2 100644 (file)
@@ -3,7 +3,7 @@
   StdIn, StdOut, StdErr, etc...).\r
 \r
   Copyright 2016 Dell Inc.\r
-  Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR>\r
   (C) Copyright 2013 Hewlett-Packard Development Company, L.P.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
@@ -1074,6 +1074,10 @@ FileInterfaceEnvClose(
            (((CHAR16*)NewBuffer)[TotalSize / sizeof (CHAR16) - 3] == CHAR_CARRIAGE_RETURN)\r
          ) {\r
         ((CHAR16*)NewBuffer)[TotalSize / sizeof (CHAR16) - 3] = CHAR_NULL;\r
+        //\r
+        // If the NewBuffer end with \r\n\0, We will repace '\r' by '\0' and then update TotalSize.\r
+        //\r
+        TotalSize -= sizeof(CHAR16) * 2;\r
       }\r
 \r
       if (Volatile) {\r