diff options
author | Ruiyu Ni <ruiyu.ni@intel.com> | 2017-10-25 09:01:27 +0800 |
---|---|---|
committer | Ruiyu Ni <ruiyu.ni@intel.com> | 2017-10-26 13:04:15 +0800 |
commit | 452676ffd895651683dcf19535e65294ff1d00d0 (patch) | |
tree | e17cf401518006a6830b028e24cf9ea7fc71d332 /ShellPkg/Library | |
parent | 704b71d7e11f115a3b5b03471d6420a7a70f1585 (diff) | |
download | edk2-452676ffd895651683dcf19535e65294ff1d00d0.zip edk2-452676ffd895651683dcf19535e65294ff1d00d0.tar.gz edk2-452676ffd895651683dcf19535e65294ff1d00d0.tar.bz2 |
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 <ruiyu.ni@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
Diffstat (limited to 'ShellPkg/Library')
-rw-r--r-- | ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.c index d26d08f..b45e9a3 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;
}
|