From: Ruiyu Ni Date: Wed, 25 Oct 2017 01:01:27 +0000 (+0800) Subject: Shellpkg/editor: Fix a bug that may modifies Line[-1] X-Git-Tag: edk2-stable201903~3181 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=452676ffd895651683dcf19535e65294ff1d00d0 Shellpkg/editor: Fix a bug that may modifies Line[-1] The original code as below intend to set the character before last column to CHAR_NULL. Line[(LastCol % (ARRAY_SIZE (Line) - 1)) - 1] = CHAR_NULL; But when LastCol % (ARRAY_SIZE (Line) - 1)) equals to 0, Line[-1] is modified. We should change to code as below: Line[(LastCol - 1) % (ARRAY_SIZE (Line) - 1)] = CHAR_NULL; Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni Reviewed-by: Jaben Carsey Reviewed-by: Hao A Wu --- diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.c index d26d08f95c..b45e9a33f3 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.c +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.c @@ -205,7 +205,7 @@ EditorClearLine ( // // if CHAR_NULL is still at position LastCol, it will cause first line error // - Line[(LastCol % (ARRAY_SIZE (Line) - 1)) - 1] = CHAR_NULL; + Line[(LastCol - 1) % (ARRAY_SIZE (Line) - 1)] = CHAR_NULL; } else { Line[LastCol % (ARRAY_SIZE (Line) - 1)] = CHAR_NULL; }