From 452676ffd895651683dcf19535e65294ff1d00d0 Mon Sep 17 00:00:00 2001 From: Ruiyu Ni Date: Wed, 25 Oct 2017 09:01:27 +0800 Subject: 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 --- .../Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ShellPkg') 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; } -- cgit v1.2.3