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 <hao.a.wu@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
This commit is contained in:
Hao Wu 2017-05-23 09:47:26 +08:00
parent 2d49938845
commit d727614c91
1 changed files with 1 additions and 1 deletions

View File

@ -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 ^
//