From b527ce3be7b615d64339e6736a92a560b80f87d0 Mon Sep 17 00:00:00 2001 From: Hao Wu Date: Tue, 23 May 2017 09:47:26 +0800 Subject: ShellPkg/UefiShellLib: Avoid reading undefined content before string 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 Reviewed-by: Jaben Carsey (cherry picked from commit d727614c913449a59e8333c4d75cff4ebf1f9779) --- Core/ShellPkg/Library/UefiShellLib/UefiShellLib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Core') diff --git a/Core/ShellPkg/Library/UefiShellLib/UefiShellLib.c b/Core/ShellPkg/Library/UefiShellLib/UefiShellLib.c index 0f37886956..c3a67c3be7 100644 --- a/Core/ShellPkg/Library/UefiShellLib/UefiShellLib.c +++ b/Core/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 ^ // -- cgit v1.2.3