* 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
|
#define grub_memcpy memcpy
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef STANDALONE
|
||||||
|
#include <assert.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef STANDALONE
|
#ifndef STANDALONE
|
||||||
#ifdef TEST
|
#ifdef TEST
|
||||||
typedef unsigned int grub_size_t;
|
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;
|
grub_size_t rs = redundancy;
|
||||||
gf_single_t *ptr = buffer;
|
gf_single_t *ptr = buffer;
|
||||||
gf_single_t *rptr = ptr + s;
|
gf_single_t *rptr = ptr + s;
|
||||||
|
void *tmp;
|
||||||
|
|
||||||
|
tmp = xmalloc (data_size);
|
||||||
|
grub_memcpy (tmp, buffer, data_size);
|
||||||
|
|
||||||
/* Nothing to do. */
|
/* Nothing to do. */
|
||||||
if (!rs)
|
if (!rs)
|
||||||
|
@ -481,6 +489,9 @@ grub_reed_solomon_add_redundancy (void *buffer, grub_size_t data_size,
|
||||||
s -= cs;
|
s -= cs;
|
||||||
rs -= crs;
|
rs -= crs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assert (grub_memcmp (tmp, buffer, data_size) == 0);
|
||||||
|
free (tmp);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -448,10 +448,14 @@ setup (const char *dir,
|
||||||
+ GRUB_KERNEL_I386_PC_REED_SOLOMON_REDUNDANCY)
|
+ GRUB_KERNEL_I386_PC_REED_SOLOMON_REDUNDANCY)
|
||||||
= grub_host_to_target32 (nsec * GRUB_DISK_SECTOR_SIZE - core_size);
|
= 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,
|
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,
|
core_size - GRUB_KERNEL_I386_PC_NO_REED_SOLOMON_PART - GRUB_DISK_SECTOR_SIZE,
|
||||||
nsec * GRUB_DISK_SECTOR_SIZE
|
nsec * GRUB_DISK_SECTOR_SIZE
|
||||||
- core_size);
|
- core_size);
|
||||||
|
assert (grub_memcmp (tmp, core_img, core_size) == 0);
|
||||||
|
free (tmp);
|
||||||
|
|
||||||
/* Make sure that the second blocklist is a terminator. */
|
/* Make sure that the second blocklist is a terminator. */
|
||||||
block = first_block - 1;
|
block = first_block - 1;
|
||||||
|
|
Loading…
Reference in a new issue