From e40b459617da712dd661e6ce906cf0f4b76e65f4 Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Fri, 31 May 2013 00:59:02 +0200 Subject: [PATCH] * grub-core/normal/cmdline.c (grub_cmdline_get): Fix Ctrl-u handling to copy the killed characters to the kill buffer as UCS4 stored as grub_uint32_t rather than as 8-bit characters stored as char. Eliminates UCS4 truncation and corruption observed when killing characters with Ctrl-u and yanking them back with Ctrl-y. --- ChangeLog | 9 +++++++++ grub-core/normal/cmdline.c | 6 +++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0da4f9e34..e9ef17e7c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2013-05-30 Josh Triplett + + * grub-core/normal/cmdline.c (grub_cmdline_get): Fix Ctrl-u + handling to copy the killed characters to the kill buffer as + UCS4 stored as grub_uint32_t rather than as 8-bit characters + stored as char. Eliminates UCS4 truncation and corruption + observed when killing characters with Ctrl-u and yanking them + back with Ctrl-y. + 2013-05-30 Vladimir Serbinenko Detach optional parts of gfxterm and integrate in with coreboot init. diff --git a/grub-core/normal/cmdline.c b/grub-core/normal/cmdline.c index 71d9bd1fc..eb974efee 100644 --- a/grub-core/normal/cmdline.c +++ b/grub-core/normal/cmdline.c @@ -587,7 +587,7 @@ grub_cmdline_get (const char *prompt_translated) grub_free (kill_buf); - kill_buf = grub_malloc (n + 1); + kill_buf = grub_malloc ((n + 1) * sizeof(grub_uint32_t)); if (grub_errno) { grub_print_error (); @@ -595,8 +595,8 @@ grub_cmdline_get (const char *prompt_translated) } if (kill_buf) { - grub_memcpy (kill_buf, buf, n); - kill_buf[n] = '\0'; + grub_memcpy (kill_buf, buf, n * sizeof(grub_uint32_t)); + kill_buf[n] = 0; } lpos = 0;