Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions grub-core/loader/efi/linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,13 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
goto fail;

filelen = grub_file_size (file);
if (filelen < (grub_off_t) sizeof (lh))
{
grub_error (GRUB_ERR_BAD_OS, N_("kernel %s size = %x is too small"),
argv[0], (unsigned) filelen);
goto fail;
}

kernel = grub_malloc(filelen);
if (!kernel)
{
Expand Down
7 changes: 6 additions & 1 deletion grub-core/loader/i386/efi/linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,12 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
goto fail;

filelen = grub_file_size (file);

if (filelen < (grub_ssize_t) sizeof (lh))
{
grub_error (GRUB_ERR_BAD_OS, N_("kernel %s size = %x is too small"),
argv[0], (unsigned) filelen);
goto fail;
}
kernel = grub_malloc(filelen);
if (!kernel)
{
Expand Down
8 changes: 8 additions & 0 deletions grub-core/loader/i386/linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,14 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
goto fail;

len = grub_file_size (file);

if (len < (grub_ssize_t) sizeof (lh))
{
grub_error (GRUB_ERR_BAD_OS, N_("kernel %s size = %x is too small"),
argv[0], (unsigned) len);
goto fail;
}

kernel = grub_malloc (len);
if (!kernel)
{
Expand Down
6 changes: 6 additions & 0 deletions grub-core/loader/i386/pc/linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,12 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
goto fail;

len = grub_file_size (file);
if (len < (grub_ssize_t) sizeof (lh))
{
grub_error (GRUB_ERR_BAD_OS, N_("kernel %s size = %x is too small"),
argv[0], (unsigned) len);
goto fail;
}
kernel = grub_malloc (len);
if (!kernel)
{
Expand Down