Reviewed-by: Jaben Carsey <jaben.car...@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...@intel.com>; Ni, Ruiyu <ruiyu...@intel.com>;
> Carsey, Jaben <jaben.car...@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...@intel.com>
> Cc: Jaben Carsey <jaben.car...@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Hao Wu <hao.a...@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

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to