Hi,
 
I found a very annoying bug in the authentication feature of grub 
(grub-core/normal/auth.c). The feature uses the function grub_printf to 
print backspaces to the screen, but the function fails to remove/override 
the last printed character and setting the cursor one step back (printing 
backspace). It simply moves the cursor one step forward, when it reveives a 
backspace character. Therfore the username entered by user is not displayed 
correctly, if the user used the backspace key (this problem has no effect 
on the input buffer; it only affects the display of the user input).
The patch I attached this mail should fix this bug. It manipulates the 
cursor directly, if the user pressed the backspace key.

--- a/grub-core/normal/auth.c
+++ b/grub-core/normal/auth.c
@@ -159,10 +159,13 @@ grub_username_get (char buf[], unsigned buf_size)
 {
   unsigned cur_len = 0;
   int key;
+  struct grub_term_output *term;
+  struct grub_term_coordinate coords;
 
   while (1)
     {
-      key = grub_getkey (); 
+      key = grub_getkey ();
+
       if (key == '\n' || key == '\r')
 	break;
 
@@ -177,7 +180,19 @@ grub_username_get (char buf[], unsigned buf_size)
 	  if (cur_len)
 	    {
 	      cur_len--;
-	      grub_printf ("\b \b");
+	      FOR_ACTIVE_TERM_OUTPUTS(term)
+	      {
+		coords=grub_term_getxy (term);
+		if (coords.x) coords.x--;
+		else
+		{
+			coords.x = grub_term_width (term);
+			coords.y--;
+		}
+		grub_term_gotoxy (term, coords);
+		grub_puts_terminal (" ", term);
+		grub_term_gotoxy (term, coords);
+	      }
 	    }
 	  continue;
 	}
_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

Reply via email to