* grub-core/lib/reed_solomon.c (grub_reed_solomon_add_redundancy): Add
an assert. * util/grub-setup.c (setup): Likewise.
This commit is contained in:
parent
1f0b1a7730
commit
31355584f1
2 changed files with 15 additions and 0 deletions
|
@ -25,6 +25,10 @@
|
|||
#define grub_memcpy memcpy
|
||||
#endif
|
||||
|
||||
#ifndef STANDALONE
|
||||
#include <assert.h>
|
||||
#endif
|
||||
|
||||
#ifndef STANDALONE
|
||||
#ifdef TEST
|
||||
typedef unsigned int grub_size_t;
|
||||
|
@ -456,6 +460,10 @@ grub_reed_solomon_add_redundancy (void *buffer, grub_size_t data_size,
|
|||
grub_size_t rs = redundancy;
|
||||
gf_single_t *ptr = buffer;
|
||||
gf_single_t *rptr = ptr + s;
|
||||
void *tmp;
|
||||
|
||||
tmp = xmalloc (data_size);
|
||||
grub_memcpy (tmp, buffer, data_size);
|
||||
|
||||
/* Nothing to do. */
|
||||
if (!rs)
|
||||
|
@ -481,6 +489,9 @@ grub_reed_solomon_add_redundancy (void *buffer, grub_size_t data_size,
|
|||
s -= cs;
|
||||
rs -= crs;
|
||||
}
|
||||
|
||||
assert (grub_memcmp (tmp, buffer, data_size) == 0);
|
||||
free (tmp);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -448,10 +448,14 @@ setup (const char *dir,
|
|||
+ GRUB_KERNEL_I386_PC_REED_SOLOMON_REDUNDANCY)
|
||||
= grub_host_to_target32 (nsec * GRUB_DISK_SECTOR_SIZE - core_size);
|
||||
|
||||
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,
|
||||
nsec * GRUB_DISK_SECTOR_SIZE
|
||||
- core_size);
|
||||
assert (grub_memcmp (tmp, core_img, core_size) == 0);
|
||||
free (tmp);
|
||||
|
||||
/* Make sure that the second blocklist is a terminator. */
|
||||
block = first_block - 1;
|
||||
|
|
Loading…
Reference in a new issue