]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ShellPkg/UefiShellLib: Avoid reading undefined content before string
authorHao Wu <hao.a.wu@intel.com>
Tue, 23 May 2017 01:47:26 +0000 (09:47 +0800)
committerHao Wu <hao.a.wu@intel.com>
Wed, 24 May 2017 05:17:51 +0000 (13:17 +0800)
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.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
ShellPkg/Library/UefiShellLib/UefiShellLib.c

index 55e8a67ac43cebe3ce1e41c62b066d35601098d0..25706e9bc32822f06b6b397205a01f20c082230e 100644 (file)
@@ -2828,7 +2828,7 @@ InternalShellPrintWorker(
     // update the attribute\r
     //\r
     if (ResumeLocation != NULL) {\r
-      if (*(ResumeLocation-1) == L'^') {\r
+      if ((ResumeLocation != mPostReplaceFormat2) && (*(ResumeLocation-1) == L'^')) {\r
         //\r
         // Move cursor back 1 position to overwrite the ^\r
         //\r