* grub-core/loader/multiboot.c (grub_cmd_module): Don't attempt to

allocate space for zero-sized modules.
This commit is contained in:
Vladimir Serbinenko 2013-10-28 14:27:19 +01:00
parent 954f7bf5ec
commit cb3c4a4722
2 changed files with 13 additions and 2 deletions

View file

@ -1,3 +1,8 @@
2013-10-28 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/loader/multiboot.c (grub_cmd_module): Don't attempt to
allocate space for zero-sized modules.
2013-10-28 Vladimir Serbinenko <phcoder@gmail.com> 2013-10-28 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/loader/xnu_resume.c (grub_xnu_resume): Reject empty images. * grub-core/loader/xnu_resume.c (grub_xnu_resume): Reject empty images.

View file

@ -316,6 +316,7 @@ grub_cmd_module (grub_command_t cmd __attribute__ ((unused)),
return grub_errno; return grub_errno;
size = grub_file_size (file); size = grub_file_size (file);
if (size)
{ {
grub_relocator_chunk_t ch; grub_relocator_chunk_t ch;
err = grub_relocator_alloc_chunk_align (grub_multiboot_relocator, &ch, err = grub_relocator_alloc_chunk_align (grub_multiboot_relocator, &ch,
@ -330,6 +331,11 @@ grub_cmd_module (grub_command_t cmd __attribute__ ((unused)),
module = get_virtual_current_address (ch); module = get_virtual_current_address (ch);
target = get_physical_target_address (ch); target = get_physical_target_address (ch);
} }
else
{
module = 0;
target = 0;
}
err = grub_multiboot_add_module (target, size, argc - 1, argv + 1); err = grub_multiboot_add_module (target, size, argc - 1, argv + 1);
if (err) if (err)
@ -338,7 +344,7 @@ grub_cmd_module (grub_command_t cmd __attribute__ ((unused)),
return err; return err;
} }
if (grub_file_read (file, module, size) != size) if (size && grub_file_read (file, module, size) != size)
{ {
grub_file_close (file); grub_file_close (file);
if (!grub_errno) if (!grub_errno)
@ -348,7 +354,7 @@ grub_cmd_module (grub_command_t cmd __attribute__ ((unused)),
} }
grub_file_close (file); grub_file_close (file);
return GRUB_ERR_NONE;; return GRUB_ERR_NONE;
} }
static grub_command_t cmd_multiboot, cmd_module; static grub_command_t cmd_multiboot, cmd_module;