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

* Re: [PATCH] ShellPkg: Fix a bug ">>v" cannot append data to environment variable
  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
  0 siblings, 0 replies; 2+ messages in thread
From: Carsey, Jaben @ 2017-01-04 17:07 UTC (permalink / raw)
  To: Ni, Ruiyu, edk2-devel@lists.01.org
  Cc: Chen, Chen A, chen881220, Carsey, Jaben

Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
Please verify appropriate copyright before commit (I guess this file needs year update).

> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of
> Ruiyu Ni
> Sent: Tuesday, January 03, 2017 7:23 PM
> To: edk2-devel@lists.01.org
> Cc: Carsey, Jaben <jaben.carsey@intel.com>; Chen, Chen A
> <chen.a.chen@intel.com>; chen881220 <ai_terran@foxmail.com>
> Subject: [edk2] [PATCH] ShellPkg: Fix a bug ">>v" cannot append data to
> environment variable
> Importance: High
> 
> 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
> 
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel


^ permalink raw reply	[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