summaryrefslogtreecommitdiff
path: root/util/grub-setup.c
diff options
context:
space:
mode:
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>2012-01-24 14:39:29 +0100
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>2012-01-24 14:39:29 +0100
commit2e13ede59e237fa4ef9b53018143c8ab0197de2c (patch)
treee6137e681f4f2c9957762194cb5ccb4638de8d49 /util/grub-setup.c
parentf8a9ab124593f070199f54f3c2de1aa670f2fca8 (diff)
Eliminate fixed limit on reed solomon decoder length.
* grub-core/boot/i386/pc/lnxboot.S: Scan for multiboot signature rather than hardcoding the address. * grub-core/boot/i386/pc/startup_raw.S: Add new data field no_reed_solomon_length. Move gate_a20 to no-reed-solomon part. Don't force a particular size of no reed-solomon part. * include/grub/offsets.h (GRUB_KERNEL_I386_PC_NO_REED_SOLOMON_PART): Removed. (GRUB_KERNEL_I386_PC_NO_REED_SOLOMON_LENGTH): New define. * util/grub-setup.c (setup): Read no_rs_length from the image itself.
Diffstat (limited to 'util/grub-setup.c')
-rw-r--r--util/grub-setup.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/util/grub-setup.c b/util/grub-setup.c
index 8965143c5..9618d1a5d 100644
--- a/util/grub-setup.c
+++ b/util/grub-setup.c
@@ -444,14 +444,22 @@ setup (const char *dir,
+ GRUB_DISK_SECTOR_SIZE
- sizeof (*block));
+ grub_size_t no_rs_length;
*(grub_uint32_t *) (core_img + GRUB_DISK_SECTOR_SIZE
+ GRUB_KERNEL_I386_PC_REED_SOLOMON_REDUNDANCY)
= grub_host_to_target32 (nsec * GRUB_DISK_SECTOR_SIZE - core_size);
+ no_rs_length = grub_target_to_host16
+ (*(grub_uint16_t *) (core_img
+ + GRUB_DISK_SECTOR_SIZE
+ + GRUB_KERNEL_I386_PC_NO_REED_SOLOMON_LENGTH));
+
+ if (no_rs_length == 0xffff)
+ grub_util_error ("core.img version mismatch");
void *tmp = xmalloc (core_size);
grub_memcpy (tmp, core_img, core_size);
- grub_reed_solomon_add_redundancy (core_img + GRUB_KERNEL_I386_PC_NO_REED_SOLOMON_PART + GRUB_DISK_SECTOR_SIZE,
- core_size - GRUB_KERNEL_I386_PC_NO_REED_SOLOMON_PART - GRUB_DISK_SECTOR_SIZE,
+ grub_reed_solomon_add_redundancy (core_img + no_rs_length + GRUB_DISK_SECTOR_SIZE,
+ core_size - no_rs_length - GRUB_DISK_SECTOR_SIZE,
nsec * GRUB_DISK_SECTOR_SIZE
- core_size);
assert (grub_memcmp (tmp, core_img, core_size) == 0);