From ee9c2e7a978cf5dd5f6eb84341ab356a87769bd3 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Thu, 15 Dec 2011 02:20:21 +0100 Subject: [PATCH] * grub-core/lib/reed_solomon.c (init_powx): Set gf_powx_inv[0] just to be deterministic. (syndroms): Compute 0 syndrom. (rs_recover): Use 0 syndrom. --- ChangeLog | 7 +++++++ grub-core/lib/reed_solomon.c | 8 +++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index ecc637e63..5a654270d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2011-12-14 Vladimir Serbinenko + + * grub-core/lib/reed_solomon.c (init_powx): Set gf_powx_inv[0] just to + be deterministic. + (syndroms): Compute 0 syndrom. + (rs_recover): Use 0 syndrom. + 2011-12-14 Vladimir Serbinenko * include/grub/kernel.h (FOR_MODULES): Make it a bit faster. diff --git a/grub-core/lib/reed_solomon.c b/grub-core/lib/reed_solomon.c index 7da5f204c..fc5443c28 100644 --- a/grub-core/lib/reed_solomon.c +++ b/grub-core/lib/reed_solomon.c @@ -89,6 +89,7 @@ init_powx (void) int i; grub_uint8_t cur = 1; + gf_powx_inv[0] = 0; for (i = 0; i < 255; i++) { gf_powx[i] = cur; @@ -165,7 +166,8 @@ syndroms (gf_single_t *m, grub_size_t s, grub_size_t rs, { gf_single_t xn = 1; unsigned i; - for (i = 0; i < rs; i++) + sy[0] = pol_evaluate (m, s + rs - 1, xn); + for (i = 1; i < rs; i++) { if (xn & (1 << (GF_SIZE - 1))) { @@ -344,7 +346,7 @@ rs_recover (gf_single_t *m, grub_size_t s, grub_size_t rs) #endif for (j = 0; j < errnum; j++) - eq[j] = errpot[j]; + eq[j] = 1; eq[errnum] = sy[0]; for (i = 1; i < (int) rs; i++) { @@ -530,7 +532,7 @@ main (int argc, char **argv) out = fopen ("tst_rs.bin", "wb"); fwrite (buf, 1, s + rs, out); fclose (out); -#if 0 +#if 1 grub_memset (buf + 512 * 15, 0, 512); #endif