2008-07-11 Pavel Roskin <proski@gnu.org>

* commands/read.c (grub_getline): Fix invalid memory access.
	Don't add newline to the variable value.
This commit is contained in:
proski 2008-07-11 17:35:06 +00:00
parent 947414b4b9
commit 0059cf6fdd
2 changed files with 12 additions and 4 deletions

View File

@ -1,5 +1,8 @@
2008-07-11 Pavel Roskin <proski@gnu.org>
* commands/read.c (grub_getline): Fix invalid memory access.
Don't add newline to the variable value.
* term/i386/pc/serial.c (GRUB_SERIAL_PORT_NUM): New constant.
[!GRUB_MACHINE_PCBIOS] (serial_hw_io_addr): Add COM2 and COM3.
(serial_hw_get_port): Check validity of the port number.

View File

@ -30,17 +30,22 @@ grub_getline (void)
int i;
char *line;
char *tmp;
char c;
i = 0;
line = grub_malloc (1 + i + sizeof('\0'));
if (! line)
return NULL;
while ((line[i - 1] != '\n') && (line[i - 1] != '\r'))
while (1)
{
line[i] = grub_getkey ();
if (grub_isprint (line[i]))
grub_putchar (line[i]);
c = grub_getkey ();
if ((c == '\n') || (c == '\r'))
break;
line[i] = c;
if (grub_isprint (c))
grub_putchar (c);
i++;
tmp = grub_realloc (line, 1 + i + sizeof('\0'));
if (! tmp)