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 <h...@n-dimensional.de>

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


_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

Reply via email to