public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH] ShellPkg/UefiShellLib: Avoid reading undefined content before string
@ 2017-05-23  2:04 Hao Wu
  2017-05-23 15:51 ` Carsey, Jaben
  0 siblings, 1 reply; 2+ messages in thread
From: Hao Wu @ 2017-05-23  2:04 UTC (permalink / raw)
  To: edk2-devel; +Cc: Hao Wu, Ruiyu Ni, Jaben Carsey

https://bugzilla.tianocore.org/show_bug.cgi?id=566

In function InternalShellPrintWorker(), if the string in variable
'mPostReplaceFormat2' starts with character L'%', the following
expression:

*(ResumeLocation-1) == L'^' at line 2831

will read an undefined value before the starting of string
'mPostReplaceFormat2'.

This commit adds additional logic to avoid reading undefined content.

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Jaben Carsey <jaben.carsey@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
---
 ShellPkg/Library/UefiShellLib/UefiShellLib.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ShellPkg/Library/UefiShellLib/UefiShellLib.c b/ShellPkg/Library/UefiShellLib/UefiShellLib.c
index 55e8a67ac4..25706e9bc3 100644
--- a/ShellPkg/Library/UefiShellLib/UefiShellLib.c
+++ b/ShellPkg/Library/UefiShellLib/UefiShellLib.c
@@ -2828,7 +2828,7 @@ InternalShellPrintWorker(
     // update the attribute
     //
     if (ResumeLocation != NULL) {
-      if (*(ResumeLocation-1) == L'^') {
+      if ((ResumeLocation != mPostReplaceFormat2) && (*(ResumeLocation-1) == L'^')) {
         //
         // Move cursor back 1 position to overwrite the ^
         //
-- 
2.12.0.windows.1



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

* Re: [PATCH] ShellPkg/UefiShellLib: Avoid reading undefined content before string
  2017-05-23  2:04 [PATCH] ShellPkg/UefiShellLib: Avoid reading undefined content before string Hao Wu
@ 2017-05-23 15:51 ` Carsey, Jaben
  0 siblings, 0 replies; 2+ messages in thread
From: Carsey, Jaben @ 2017-05-23 15:51 UTC (permalink / raw)
  To: Wu, Hao A, edk2-devel@lists.01.org; +Cc: Ni, Ruiyu

Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>

> -----Original Message-----
> From: Wu, Hao A
> Sent: Monday, May 22, 2017 7:04 PM
> To: edk2-devel@lists.01.org
> Cc: Wu, Hao A <hao.a.wu@intel.com>; Ni, Ruiyu <ruiyu.ni@intel.com>;
> Carsey, Jaben <jaben.carsey@intel.com>
> Subject: [PATCH] ShellPkg/UefiShellLib: Avoid reading undefined content
> before string
> Importance: High
> 
> https://bugzilla.tianocore.org/show_bug.cgi?id=566
> 
> In function InternalShellPrintWorker(), if the string in variable
> 'mPostReplaceFormat2' starts with character L'%', the following
> expression:
> 
> *(ResumeLocation-1) == L'^' at line 2831
> 
> will read an undefined value before the starting of string
> 'mPostReplaceFormat2'.
> 
> This commit adds additional logic to avoid reading undefined content.
> 
> Cc: Ruiyu Ni <ruiyu.ni@intel.com>
> Cc: Jaben Carsey <jaben.carsey@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Hao Wu <hao.a.wu@intel.com>
> ---
>  ShellPkg/Library/UefiShellLib/UefiShellLib.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/ShellPkg/Library/UefiShellLib/UefiShellLib.c
> b/ShellPkg/Library/UefiShellLib/UefiShellLib.c
> index 55e8a67ac4..25706e9bc3 100644
> --- a/ShellPkg/Library/UefiShellLib/UefiShellLib.c
> +++ b/ShellPkg/Library/UefiShellLib/UefiShellLib.c
> @@ -2828,7 +2828,7 @@ InternalShellPrintWorker(
>      // update the attribute
>      //
>      if (ResumeLocation != NULL) {
> -      if (*(ResumeLocation-1) == L'^') {
> +      if ((ResumeLocation != mPostReplaceFormat2) && (*(ResumeLocation-
> 1) == L'^')) {
>          //
>          // Move cursor back 1 position to overwrite the ^
>          //
> --
> 2.12.0.windows.1



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

end of thread, other threads:[~2017-05-23 15:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-23  2:04 [PATCH] ShellPkg/UefiShellLib: Avoid reading undefined content before string Hao Wu
2017-05-23 15:51 ` Carsey, Jaben

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