merge mainline into newreloc

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2010-08-28 16:04:32 +02:00
commit c5c8cf354c
10 changed files with 104 additions and 41 deletions

View file

@ -1,3 +1,48 @@
2010-08-28 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/normal/term.c (print_more): Fix a memory leak.
(grub_puts_terminal): Revert to dumb puts if memory allocation fails.
(grub_xputs_normal): Likewise.
2010-08-28 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/script/lexer.c (grub_script_lexer_init): Don't look before
the begining of the string
2010-08-28 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/script/script.c (grub_script_parse): Free parsed on
failure.
2010-08-28 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/normal/completion.c (grub_normal_do_completion): Free argv
on failure.
2010-08-28 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/normal/cmdline.c (grub_cmdline_get): Free cl_terms on
return.
2010-08-28 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/term/gfxterm.c (grub_gfxterm_term_fini): Free the text buffer.
(scroll_up): Fix a memory leak.
2010-08-28 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/fs/nilfs2.c (grub_nilfs2_load_sb): Handle grub_disk_read
errors.
2010-08-27 Vladimir Serbinenko <phcoder@gmail.com>
Handle USB pendrives exposed as floppies.
* grub-core/boot/i386/pc/boot.S: Check LBA even on what appears to be
floppy.
* grub-core/disk/i386/pc/biosdisk.c (grub_biosdisk_open): Likewise.
Check for partitions on all devices.
2010-08-25 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/term/ieee1275/ofconsole.c (put): Correct prototype.

View file

@ -153,10 +153,6 @@ real_start:
/* set %si to the disk address packet */
movw $disk_address_packet, %si
/* do not probe LBA if the drive is a floppy */
testb $GRUB_BOOT_MACHINE_BIOS_HD_FLAG, %dl
jz LOCAL(chs_mode)
/* check if LBA is supported */
movb $0x41, %ah
movw $0x55aa, %bx

View file

@ -107,7 +107,7 @@ grub_biosdisk_open (const char *name, grub_disk_t disk)
if (drive < 0)
return grub_errno;
disk->has_partitions = ((drive & 0x80) && (drive != cd_drive));
disk->has_partitions = 1;
disk->id = drive;
data = (struct grub_biosdisk_data *) grub_zalloc (sizeof (*data));
@ -123,7 +123,7 @@ grub_biosdisk_open (const char *name, grub_disk_t disk)
/* TODO: get the correct size. */
total_sectors = GRUB_DISK_SIZE_UNKNOWN;
}
else if (drive & 0x80)
else
{
/* HDD */
int version;

View file

@ -718,10 +718,13 @@ grub_nilfs2_load_sb (struct grub_nilfs2_data *data)
grub_uint64_t partition_size;
int valid[2];
int swp = 0;
grub_err_t err;
/* Read first super block. */
grub_disk_read (disk, NILFS_1ST_SUPER_BLOCK, 0,
err = grub_disk_read (disk, NILFS_1ST_SUPER_BLOCK, 0,
sizeof (struct grub_nilfs2_super_block), &data->sblock);
if (err)
return err;
/* Make sure if 1st super block is valid. */
valid[0] = grub_nilfs2_valid_sb (&data->sblock);
@ -729,8 +732,14 @@ grub_nilfs2_load_sb (struct grub_nilfs2_data *data)
if (partition_size != GRUB_DISK_SIZE_UNKNOWN)
{
/* Read second super block. */
grub_disk_read (disk, NILFS_2ND_SUPER_BLOCK (partition_size), 0,
err = grub_disk_read (disk, NILFS_2ND_SUPER_BLOCK (partition_size), 0,
sizeof (struct grub_nilfs2_super_block), &sb2);
if (err)
{
valid[1] = 0;
grub_errno = GRUB_ERR_NONE;
}
else
/* Make sure if 2nd super block is valid. */
valid[1] = grub_nilfs2_valid_sb (&sb2);
}
@ -738,8 +747,6 @@ grub_nilfs2_load_sb (struct grub_nilfs2_data *data)
/* 2nd super block may not exist, so it's invalid. */
valid[1] = 0;
if (!valid[0] && !valid[1])
return grub_error (GRUB_ERR_BAD_FS, "not a nilfs2 filesystem");
@ -752,8 +759,7 @@ grub_nilfs2_load_sb (struct grub_nilfs2_data *data)
grub_memcpy (&data->sblock, &sb2,
sizeof (struct grub_nilfs2_super_block));
grub_errno = GRUB_ERR_NONE;
return grub_errno;
return GRUB_ERR_NONE;
}
static struct grub_nilfs2_data *

View file

@ -585,6 +585,7 @@ grub_cmdline_get (const char *prompt)
break;
case '\e':
grub_free (cl_terms);
return 0;
case '\b':
@ -635,5 +636,6 @@ grub_cmdline_get (const char *prompt)
ret = grub_ucs4_to_utf8_alloc (buf + lpos, llen - lpos + 1);
grub_free (buf);
grub_free (cl_terms);
return ret;
}

View file

@ -499,7 +499,10 @@ grub_normal_do_completion (char *buf, int *restore,
fail:
if (argc != 0)
{
grub_free (argv);
grub_free (argv[0]);
}
grub_free (match);
grub_errno = GRUB_ERR_NONE;

View file

@ -44,6 +44,9 @@ static int grub_more;
static int grub_normal_char_counter = 0;
static void
putcode_real (grub_uint32_t code, struct grub_term_output *term);
int
grub_normal_get_char_counter (void)
{
@ -94,6 +97,7 @@ print_more (void)
FOR_ACTIVE_TERM_OUTPUTS(term)
grub_print_spaces (term, 8);
grub_term_restore_pos (pos);
grub_free (pos);
/* Scroll one lines or an entire page, depending on the key. */
@ -204,6 +208,20 @@ grub_puts_terminal (const char *str, struct grub_term_output *term)
grub_uint32_t *unicode_str, *unicode_last_position;
grub_utf8_to_ucs4_alloc (str, &unicode_str,
&unicode_last_position);
if (!unicode_str)
{
for (; str; str++)
{
grub_uint32_t code = *str;
if (code > 0x7f)
code = '?';
putcode_real (term, code);
if (code == '\n')
putcode_real (term, '\r');
}
return;
}
grub_print_ucs4 (unicode_str, unicode_last_position, 0, 0, term);
grub_free (unicode_str);
@ -760,22 +778,9 @@ grub_xputs_normal (const char *str)
FOR_ACTIVE_TERM_OUTPUTS(term)
{
struct grub_unicode_glyph c =
{
.base = code,
.variant = 0,
.attributes = 0,
.ncomb = 0,
.combining = 0,
.estimated_width = 1
};
(term->putchar) (term, &c);
putcode_real (term, code);
if (code == '\n')
{
c.base = '\r';
(term->putchar) (term, &c);
}
putcode_real (term, '\r');
}
}

View file

@ -236,7 +236,7 @@ grub_script_lexer_init (struct grub_parser_param *parser, char *script,
script = script ? : "\n";
len = grub_strlen (script);
if (script[len - 1] == '\n')
if (len != 0 && script[len - 1] == '\n')
{
buffer = yy_scan_string (script, lexerstate->yyscanner);
}

View file

@ -365,7 +365,10 @@ grub_script_parse (char *script, grub_reader_getline_t getline)
parsestate = grub_zalloc (sizeof (*parsestate));
if (!parsestate)
{
grub_free (parsed);
return 0;
}
/* Initialize the lexer. */
lexstate = grub_script_lexer_init (parsestate, script, getline);
@ -388,6 +391,7 @@ grub_script_parse (char *script, grub_reader_getline_t getline)
grub_script_mem_free (memfree);
grub_script_lexer_fini (lexstate);
grub_free (parsestate);
grub_free (parsed);
return 0;
}

View file

@ -405,9 +405,16 @@ destroy_window (void)
static grub_err_t
grub_gfxterm_term_fini (struct grub_term_output *term __attribute__ ((unused)))
{
unsigned i;
destroy_window ();
grub_video_restore ();
for (i = 0; i < virtual_screen.columns * virtual_screen.rows; i++)
{
grub_free (virtual_screen.text_buffer[i].code);
virtual_screen.text_buffer[i].code = 0;
}
/* Clear error state. */
grub_errno = GRUB_ERR_NONE;
return GRUB_ERR_NONE;
@ -793,13 +800,8 @@ scroll_up (void)
unsigned int i;
/* Clear first line in text buffer. */
for (i = 0;
i < virtual_screen.columns;
i++)
{
virtual_screen.text_buffer[i].code = 0;
clear_char (&(virtual_screen.text_buffer[i]));
}
for (i = 0; i < virtual_screen.columns; i++)
grub_free (virtual_screen.text_buffer[i].code);
/* Scroll text buffer with one line to up. */
grub_memmove (virtual_screen.text_buffer,