* grub-core/lib/reed_solomon.c (decode_block): Allocate on heap and not

stack.
	(encode_block): Likewise.
This commit is contained in:
Vladimir 'phcoder' Serbinenko 2011-12-15 19:27:01 +01:00
parent 276b7a8bdd
commit 96f8caf812
2 changed files with 27 additions and 2 deletions

View file

@ -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

View 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