]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
* grub-core/lib/reed_solomon.c (gauss_solve): Fix size of standalone
authorColin Watson <cjwatson@ubuntu.com>
Tue, 21 Dec 2010 16:51:08 +0000 (16:51 +0000)
committerColin Watson <cjwatson@ubuntu.com>
Tue, 21 Dec 2010 16:51:08 +0000 (16:51 +0000)
scratch area.  Make sure to initialise chosen in standalone mode as
well as non-standalone.
Reported by: Robert Hooker and Andy Whitcroft.
Tested by: Andy Whitcroft.

ChangeLog
grub-core/lib/reed_solomon.c

index e65dc231ce8f907986509b5e0cd2a1cebbcd9b3f..4c7225bc5c232a7690c2cd688cd5f3f145ab873a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2010-12-21  Colin Watson  <cjwatson@ubuntu.com>
+
+       * grub-core/lib/reed_solomon.c (gauss_solve): Fix size of standalone
+       scratch area.  Make sure to initialise chosen in standalone mode as
+       well as non-standalone.
+       Reported by: Robert Hooker and Andy Whitcroft.
+       Tested by: Andy Whitcroft.
+
 2010-12-21  Colin Watson  <cjwatson@ubuntu.com>
 
        * grub-core/commands/echo.c (grub_cmd_echo): Make UTF-8-clean by
index 4c6e160e48ee0daec3b315589442609cf20697eb..6f571550a2a5a1923e422e4c8beb16ee2f97e985 100644 (file)
@@ -18,6 +18,8 @@
 
 #ifdef TEST
 #include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
 #define xmalloc malloc
 #define grub_memset memset
 #define grub_memcpy memcpy
@@ -25,8 +27,6 @@
 
 #ifndef STANDALONE
 #ifdef TEST
-#include <string.h>
-#include <stdlib.h>
 typedef unsigned int grub_size_t;
 typedef unsigned char grub_uint8_t;
 typedef unsigned short grub_uint16_t;
@@ -45,6 +45,7 @@ typedef unsigned char grub_uint8_t;
 typedef unsigned short grub_uint16_t;
 #else
 #include <grub/types.h>
+#include <grub/misc.h>
 #endif
 void
 grub_reed_solomon_recover (void *ptr_, grub_size_t s, grub_size_t rs);
@@ -207,11 +208,12 @@ gauss_solve (gf_single_t *eq, int n, int m, gf_single_t *sol)
 
 #ifndef STANDALONE
   chosen = xmalloc (n * sizeof (int));
-  grub_memset (chosen, -1, n * sizeof (int));
 #else
   chosen = (void *) scratch;
-  scratch += n;
+  scratch += n * sizeof (int);
 #endif
+  for (i = 0; i < n; i++)
+    chosen[i] = -1;
   for (i = 0; i < m; i++)
     sol[i] = 0;
   gauss_eliminate (eq, n, m, chosen);
@@ -228,7 +230,7 @@ gauss_solve (gf_single_t *eq, int n, int m, gf_single_t *sol)
 #ifndef STANDALONE
   free (chosen);
 #else
-  scratch -= n;
+  scratch -= n * sizeof (int);
 #endif
 }