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:
parent
947414b4b9
commit
0059cf6fdd
2 changed files with 12 additions and 4 deletions
|
@ -1,5 +1,8 @@
|
||||||
2008-07-11 Pavel Roskin <proski@gnu.org>
|
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.
|
* term/i386/pc/serial.c (GRUB_SERIAL_PORT_NUM): New constant.
|
||||||
[!GRUB_MACHINE_PCBIOS] (serial_hw_io_addr): Add COM2 and COM3.
|
[!GRUB_MACHINE_PCBIOS] (serial_hw_io_addr): Add COM2 and COM3.
|
||||||
(serial_hw_get_port): Check validity of the port number.
|
(serial_hw_get_port): Check validity of the port number.
|
||||||
|
|
|
@ -30,17 +30,22 @@ grub_getline (void)
|
||||||
int i;
|
int i;
|
||||||
char *line;
|
char *line;
|
||||||
char *tmp;
|
char *tmp;
|
||||||
|
char c;
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
line = grub_malloc (1 + i + sizeof('\0'));
|
line = grub_malloc (1 + i + sizeof('\0'));
|
||||||
if (! line)
|
if (! line)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
while ((line[i - 1] != '\n') && (line[i - 1] != '\r'))
|
while (1)
|
||||||
{
|
{
|
||||||
line[i] = grub_getkey ();
|
c = grub_getkey ();
|
||||||
if (grub_isprint (line[i]))
|
if ((c == '\n') || (c == '\r'))
|
||||||
grub_putchar (line[i]);
|
break;
|
||||||
|
|
||||||
|
line[i] = c;
|
||||||
|
if (grub_isprint (c))
|
||||||
|
grub_putchar (c);
|
||||||
i++;
|
i++;
|
||||||
tmp = grub_realloc (line, 1 + i + sizeof('\0'));
|
tmp = grub_realloc (line, 1 + i + sizeof('\0'));
|
||||||
if (! tmp)
|
if (! tmp)
|
||||||
|
|
Loading…
Reference in a new issue