From cb3c4a472256801d934836f8957d14fb8d683fdd Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 28 Oct 2013 14:27:19 +0100 Subject: [PATCH] * grub-core/loader/multiboot.c (grub_cmd_module): Don't attempt to allocate space for zero-sized modules. --- ChangeLog | 5 +++++ grub-core/loader/multiboot.c | 10 ++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4b69844d9..7319fb8cf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2013-10-28 Vladimir Serbinenko + + * grub-core/loader/multiboot.c (grub_cmd_module): Don't attempt to + allocate space for zero-sized modules. + 2013-10-28 Vladimir Serbinenko * grub-core/loader/xnu_resume.c (grub_xnu_resume): Reject empty images. diff --git a/grub-core/loader/multiboot.c b/grub-core/loader/multiboot.c index a37826c5d..7b6734923 100644 --- a/grub-core/loader/multiboot.c +++ b/grub-core/loader/multiboot.c @@ -316,6 +316,7 @@ grub_cmd_module (grub_command_t cmd __attribute__ ((unused)), return grub_errno; size = grub_file_size (file); + if (size) { grub_relocator_chunk_t 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); target = get_physical_target_address (ch); } + else + { + module = 0; + target = 0; + } err = grub_multiboot_add_module (target, size, argc - 1, argv + 1); if (err) @@ -338,7 +344,7 @@ grub_cmd_module (grub_command_t cmd __attribute__ ((unused)), return err; } - if (grub_file_read (file, module, size) != size) + if (size && grub_file_read (file, module, size) != size) { grub_file_close (file); if (!grub_errno) @@ -348,7 +354,7 @@ grub_cmd_module (grub_command_t cmd __attribute__ ((unused)), } grub_file_close (file); - return GRUB_ERR_NONE;; + return GRUB_ERR_NONE; } static grub_command_t cmd_multiboot, cmd_module;