From 1c4ad986aa89b41f8478ae94689557f362c9fe82 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sat, 16 Jan 2010 17:18:02 +0100 Subject: [PATCH] size field in tagged mbi --- loader/i386/multiboot_mbi2.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/loader/i386/multiboot_mbi2.c b/loader/i386/multiboot_mbi2.c index de234727b..636b63923 100644 --- a/loader/i386/multiboot_mbi2.c +++ b/loader/i386/multiboot_mbi2.c @@ -62,7 +62,7 @@ static grub_uint32_t biosdev, slice, part; grub_size_t grub_multiboot_get_mbi_size (void) { - return sizeof (struct multiboot_tag) + return sizeof (grub_uint32_t) + sizeof (struct multiboot_tag) + (sizeof (struct multiboot_tag_string) + ALIGN_UP (cmdline_size, 4)) + (sizeof (struct multiboot_tag_string) + ALIGN_UP (sizeof (PACKAGE_STRING), 4)) @@ -221,12 +221,15 @@ grub_err_t grub_multiboot_make_mbi (void *orig, grub_uint32_t dest, grub_off_t buf_off, grub_size_t bufsize) { - grub_uint8_t *ptrorig = (grub_uint8_t *) orig + buf_off; + grub_uint8_t *ptrorig; + grub_uint8_t *mbistart = (grub_uint8_t *) orig + buf_off; grub_err_t err; if (bufsize < grub_multiboot_get_mbi_size ()) return grub_error (GRUB_ERR_OUT_OF_MEMORY, "mbi buffer is too small"); + ptrorig = (grub_uint8_t *) orig + buf_off + sizeof (grub_uint32_t); + { struct multiboot_tag_string *tag = (struct multiboot_tag_string *) ptrorig; tag->type = MULTIBOOT_TAG_TYPE_CMDLINE; @@ -314,6 +317,8 @@ grub_multiboot_make_mbi (void *orig, grub_uint32_t dest, grub_off_t buf_off, ptrorig += tag->size; } + *(grub_uint32_t *) mbistart = ptrorig - mbistart; + return GRUB_ERR_NONE; }