* grub-core/lib/reed_solomon.c (grub_reed_solomon_add_redundancy):

Prevent overflow.
	(grub_reed_solomon_recover): Likewise.
This commit is contained in:
Vladimir 'phcoder' Serbinenko 2011-01-04 15:39:59 +01:00
parent e5146ca18b
commit a0159f370d
2 changed files with 10 additions and 4 deletions

View file

@ -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>
* grub-core/lib/reed_solomon.c (main) [TEST]: Reactivate normal test.

View file

@ -433,8 +433,8 @@ grub_reed_solomon_add_redundancy (void *buffer, grub_size_t data_size,
tt = cs + crs;
if (tt > MAX_BLOCK_SIZE)
{
cs = (cs * MAX_BLOCK_SIZE) / tt;
crs = (crs * MAX_BLOCK_SIZE) / tt;
cs = ((cs * (MAX_BLOCK_SIZE / 512)) / tt) * 512;
crs = ((crs * (MAX_BLOCK_SIZE / 512)) / tt) * 512;
}
encode_block (ptr, cs, rptr, crs);
ptr += cs;
@ -468,8 +468,8 @@ grub_reed_solomon_recover (void *ptr_, grub_size_t s, grub_size_t rs)
tt = cs + crs;
if (tt > MAX_BLOCK_SIZE)
{
cs = (cs * MAX_BLOCK_SIZE) / tt;
crs = (crs * MAX_BLOCK_SIZE) / tt;
cs = ((cs * (MAX_BLOCK_SIZE / 512)) / tt) * 512;
crs = ((crs * (MAX_BLOCK_SIZE / 512)) / tt) * 512;
}
decode_block (ptr, cs, rptr, crs);
ptr += cs;