* grub-core/lib/reed_solomon.c (grub_reed_solomon_add_redundancy):
Prevent overflow. (grub_reed_solomon_recover): Likewise.
This commit is contained in:
parent
e5146ca18b
commit
a0159f370d
2 changed files with 10 additions and 4 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
2011-01-04 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
* grub-core/lib/reed_solomon.c (grub_reed_solomon_add_redundancy):
|
||||||
|
Prevent overflow.
|
||||||
|
(grub_reed_solomon_recover): Likewise.
|
||||||
|
|
||||||
2011-01-04 Vladimir Serbinenko <phcoder@gmail.com>
|
2011-01-04 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
* grub-core/lib/reed_solomon.c (main) [TEST]: Reactivate normal test.
|
* grub-core/lib/reed_solomon.c (main) [TEST]: Reactivate normal test.
|
||||||
|
|
|
@ -433,8 +433,8 @@ grub_reed_solomon_add_redundancy (void *buffer, grub_size_t data_size,
|
||||||
tt = cs + crs;
|
tt = cs + crs;
|
||||||
if (tt > MAX_BLOCK_SIZE)
|
if (tt > MAX_BLOCK_SIZE)
|
||||||
{
|
{
|
||||||
cs = (cs * MAX_BLOCK_SIZE) / tt;
|
cs = ((cs * (MAX_BLOCK_SIZE / 512)) / tt) * 512;
|
||||||
crs = (crs * MAX_BLOCK_SIZE) / tt;
|
crs = ((crs * (MAX_BLOCK_SIZE / 512)) / tt) * 512;
|
||||||
}
|
}
|
||||||
encode_block (ptr, cs, rptr, crs);
|
encode_block (ptr, cs, rptr, crs);
|
||||||
ptr += cs;
|
ptr += cs;
|
||||||
|
@ -468,8 +468,8 @@ grub_reed_solomon_recover (void *ptr_, grub_size_t s, grub_size_t rs)
|
||||||
tt = cs + crs;
|
tt = cs + crs;
|
||||||
if (tt > MAX_BLOCK_SIZE)
|
if (tt > MAX_BLOCK_SIZE)
|
||||||
{
|
{
|
||||||
cs = (cs * MAX_BLOCK_SIZE) / tt;
|
cs = ((cs * (MAX_BLOCK_SIZE / 512)) / tt) * 512;
|
||||||
crs = (crs * MAX_BLOCK_SIZE) / tt;
|
crs = ((crs * (MAX_BLOCK_SIZE / 512)) / tt) * 512;
|
||||||
}
|
}
|
||||||
decode_block (ptr, cs, rptr, crs);
|
decode_block (ptr, cs, rptr, crs);
|
||||||
ptr += cs;
|
ptr += cs;
|
||||||
|
|
Loading…
Reference in a new issue