]> git.proxmox.com Git - grub2.git/commitdiff
* grub-core/lib/reed_solomon.c (decode_block): Allocate on heap and not
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Thu, 15 Dec 2011 18:27:01 +0000 (19:27 +0100)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Thu, 15 Dec 2011 18:27:01 +0000 (19:27 +0100)
stack.
(encode_block): Likewise.

ChangeLog
grub-core/lib/reed_solomon.c

index c59df38c2e83bdc3373cc0d772a3e4b83891e1e0..0063cdf04b10ae6c00e21b5c9826a54a24da7caa 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2011-12-15  Vladimir Serbinenko  <phcoder@gmail.com>
+
+       * grub-core/lib/reed_solomon.c (decode_block): Allocate on heap and not
+       stack.
+       (encode_block): Likewise.
+
 2011-12-15  Vladimir Serbinenko  <phcoder@gmail.com>
 
        * grub-core/boot/i386/pc/startup_raw.S: Clear direction flag for
index fc5443c28e5d48ec1bdea5a46da79390955fa85b..3d8bb9e1f4fe101b69c4645ac865a0bade336341 100644 (file)
@@ -390,12 +390,19 @@ decode_block (gf_single_t *ptr, grub_size_t s,
     {
       grub_size_t ds = (s + SECTOR_SIZE - 1 - i) / SECTOR_SIZE;
       grub_size_t rr = (rs + SECTOR_SIZE - 1 - i) / SECTOR_SIZE;
-      gf_single_t m[ds + rr];
+      gf_single_t *m;
 
       /* Nothing to do.  */
       if (!ds || !rr)
        continue;
 
+#ifndef STANDALONE
+      m = xmalloc (ds + rr);
+#else
+      m = (gf_single_t *) scratch;
+      scratch += ds + rr;
+#endif
+
       for (j = 0; j < (int) ds; j++)
        m[j] = ptr[SECTOR_SIZE * j + i];
       for (j = 0; j < (int) rr; j++)
@@ -405,6 +412,12 @@ decode_block (gf_single_t *ptr, grub_size_t s,
 
       for (j = 0; j < (int) ds; j++)
        ptr[SECTOR_SIZE * j + i] = m[j];
+
+#ifndef STANDALONE
+      free (m);
+#else
+      scratch -= ds + rr;
+#endif
     }
 }
 
@@ -418,12 +431,18 @@ encode_block (gf_single_t *ptr, grub_size_t s,
     {
       grub_size_t ds = (s + SECTOR_SIZE - 1 - i) / SECTOR_SIZE;
       grub_size_t rr = (rs + SECTOR_SIZE - 1 - i) / SECTOR_SIZE;
-      gf_single_t m[ds + rr];
+      gf_single_t *m;
+
+      if (!ds || !rr)
+       continue;
+
+      m = xmalloc (ds + rr);
       for (j = 0; j < ds; j++)
        m[j] = ptr[SECTOR_SIZE * j + i];
       rs_encode (m, ds, rr);
       for (j = 0; j < rr; j++)      
        rptr[SECTOR_SIZE * j + i] = m[j + ds];
+      free (m);
     }
 }
 #endif