[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] mb2 loader: Fix header size, alignment for Multiboot 2
From: |
Hans Ulrich Niedermann |
Subject: |
[PATCH] mb2 loader: Fix header size, alignment for Multiboot 2 |
Date: |
Sat, 23 May 2020 22:19:22 +0200 |
Change the old Multiboot 1 header size both in the explanatory
comment and in the for loop condition actually looking for a
Multiboot 2 header to the actual Multiboot 2 header size.
This also fixes the old Multiboot 1 alignment copied over
in the comment to reflect the Multiboot 2 specification.
Signed-off-by: Hans Ulrich Niedermann <address@hidden>
diff --git a/grub-core/loader/multiboot_mbi2.c
b/grub-core/loader/multiboot_mbi2.c
index a5f9a94a2..026109e69 100644
--- a/grub-core/loader/multiboot_mbi2.c
+++ b/grub-core/loader/multiboot_mbi2.c
@@ -90,10 +90,11 @@ static struct multiboot_header *
find_header (grub_properly_aligned_t *buffer, grub_ssize_t len)
{
struct multiboot_header *header;
- /* Look for the multiboot header in the buffer. The header should
- be at least 12 bytes and aligned on a 4-byte boundary. */
+ /* Look for the Multiboot 2 header magic in the buffer. The
+ complete MB2 header should be at least 16+8=24 bytes (header
+ magic plus terminator tag) and aligned on an 8-byte boundary. */
for (header = (struct multiboot_header *) buffer;
- ((char *) header <= (char *) buffer + len - 12);
+ ((char *) header <= (char *) buffer + len - 24);
header = (struct multiboot_header *) ((grub_uint32_t *) header +
MULTIBOOT_HEADER_ALIGN / 4))
{
if (header->magic == MULTIBOOT2_HEADER_MAGIC
--
2.26.2