]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Shellpkg/editor: Fix a bug that may modifies Line[-1]
authorRuiyu Ni <ruiyu.ni@intel.com>
Wed, 25 Oct 2017 01:01:27 +0000 (09:01 +0800)
committerRuiyu Ni <ruiyu.ni@intel.com>
Thu, 26 Oct 2017 05:04:15 +0000 (13:04 +0800)
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>
ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.c

index d26d08f95c14c365ce2c6990eb55681172978950..b45e9a33f393529bfbb33ef9715c108d43e5e232 100644 (file)
@@ -205,7 +205,7 @@ EditorClearLine (
         //\r
         // if CHAR_NULL is still at position LastCol, it will cause first line error\r
         //\r
-        Line[(LastCol % (ARRAY_SIZE (Line) - 1)) - 1] = CHAR_NULL;\r
+        Line[(LastCol - 1) % (ARRAY_SIZE (Line) - 1)] = CHAR_NULL;\r
       } else {\r
         Line[LastCol % (ARRAY_SIZE (Line) - 1)] = CHAR_NULL;\r
       }\r