public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Ruiyu Ni <ruiyu.ni@intel.com>
To: edk2-devel@lists.01.org
Cc: chen881220 <ai_terran@foxmail.com>,
	Chen A Chen <chen.a.chen@intel.com>,
	Jaben Carsey <jaben.carsey@intel.com>
Subject: [PATCH] ShellPkg: Fix a bug ">>v" cannot append data to environment variable
Date: Wed,  4 Jan 2017 11:23:08 +0800	[thread overview]
Message-ID: <20170104032308.476512-1-ruiyu.ni@intel.com> (raw)

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



             reply	other threads:[~2017-01-04  3:23 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-04  3:23 Ruiyu Ni [this message]
2017-01-04 17:07 ` [PATCH] ShellPkg: Fix a bug ">>v" cannot append data to environment variable Carsey, Jaben

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170104032308.476512-1-ruiyu.ni@intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox