]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
loader/linux: Make trailer initrd entry aligned again.
authorBernhard Übelacker <bernhardu@vr-web.de>
Mon, 20 Jul 2015 12:06:45 +0000 (14:06 +0200)
committerAndrei Borzenkov <arvidjaar@gmail.com>
Mon, 20 Jul 2015 16:07:20 +0000 (19:07 +0300)
Regression from commit:
  loader/linux: do not pad initrd with zeroes at the end
  a8c473288d3f0a5e17a903a5121dea1a695dda3b

Wimboot fails since the change above because it expects the "trailer"
initrd element on an aligned address.
This issue shows only when newc_name is used and the last initrd
entry has a not aligned size.

grub-core/loader/linux.c

index d2cd591f60480b0c672329916dbe7e86ed9164e4..be6fa0f4d45126f1ca5f67925241a8a6a944ae45 100644 (file)
@@ -213,6 +213,7 @@ grub_initrd_init (int argc, char *argv[],
 
   if (newc)
     {
+      initrd_ctx->size = ALIGN_UP (initrd_ctx->size, 4);
       initrd_ctx->size += ALIGN_UP (sizeof (struct newc_head)
                                    + sizeof ("TRAILER!!!") - 1, 4);
       free_dir (root);
@@ -290,7 +291,11 @@ grub_initrd_load (struct grub_linux_initrd_context *initrd_ctx,
       ptr += cursize;
     }
   if (newc)
-    ptr = make_header (ptr, "TRAILER!!!", sizeof ("TRAILER!!!") - 1, 0, 0);
+    {
+      grub_memset (ptr, 0, ALIGN_UP_OVERHEAD (cursize, 4));
+      ptr += ALIGN_UP_OVERHEAD (cursize, 4);
+      ptr = make_header (ptr, "TRAILER!!!", sizeof ("TRAILER!!!") - 1, 0, 0);
+    }
   free_dir (root);
   root = 0;
   return GRUB_ERR_NONE;