From: Glenn Washburn <development@efficientek.com>
To: grub-devel@gnu.org, Daniel Kiper <dkiper@net-space.pl>
Cc: Li Gen <ligenlive@gmail.com>,
Glenn Washburn <development@efficientek.com>
Subject: [PATCH] read: Fix overflow in grub_getline()
Date: Thu, 25 Aug 2022 19:59:09 -0500 [thread overview]
Message-ID: <20220826005909.360621-1-development@efficientek.com> (raw)
From: Li Gen <ligenlive@gmail.com>
Store returned value from grub_getkey() in int instead of char to
prevent throwing away the extended bits. This was a problem because,
for instance, the left arrow key press would return
(GRUB_TERM_EXTENDED | 0x4b), which would have the GRUB_TERM_EXTENDED
thrown away leaving 0x4b or 'K'. These extended keys should either
work as intended or do nothing. This change has them do nothing, instead
of inserting a key not pressed by the user.
Signed-off-by: Li Gen <ligenlive@gmail.com>
Signed-off-by: Glenn Washburn <development@efficientek.com>
---
grub-core/commands/read.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/grub-core/commands/read.c b/grub-core/commands/read.c
index c2969ccda4..597c907065 100644
--- a/grub-core/commands/read.c
+++ b/grub-core/commands/read.c
@@ -40,7 +40,7 @@ grub_getline (int silent)
int i;
char *line;
char *tmp;
- char c;
+ int c;
i = 0;
line = grub_malloc (1 + i + sizeof('\0'));
@@ -53,8 +53,11 @@ grub_getline (int silent)
if ((c == '\n') || (c == '\r'))
break;
- line[i] = c;
- if (!silent && grub_isprint (c))
+ if (!grub_isprint (c))
+ continue;
+
+ line[i] = (char) c;
+ if (!silent)
grub_printf ("%c", c);
i++;
tmp = grub_realloc (line, 1 + i + sizeof('\0'));
--
2.34.1
next reply other threads:[~2022-08-26 0:59 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-26 0:59 Glenn Washburn [this message]
2022-09-29 15:46 ` [PATCH] read: Fix overflow in grub_getline() Daniel Kiper
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220826005909.360621-1-development@efficientek.com \
--to=development@efficientek.com \
--cc=dkiper@net-space.pl \
--cc=grub-devel@gnu.org \
--cc=ligenlive@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.