2010-01-27 Robert Millan <rmh.grub@aybabtu.com>

* kern/disk.c (grub_disk_read): Fix bug that would cause infinite
	loop when using read hooks on files whose size isn't sector-aligned.
This commit is contained in:
Robert Millan 2010-01-27 03:15:03 +00:00
parent c294d9d812
commit 67667b9ced
2 changed files with 11 additions and 4 deletions

View file

@ -1,3 +1,8 @@
2010-01-27 Robert Millan <rmh.grub@aybabtu.com>
* kern/disk.c (grub_disk_read): Fix bug that would cause infinite
loop when using read hooks on files whose size isn't sector-aligned.
2010-01-27 Robert Millan <rmh.grub@aybabtu.com>
Remove unused parameter.

View file

@ -464,12 +464,14 @@ grub_disk_read (grub_disk_t disk, grub_disk_addr_t sector,
if (disk->read_hook)
while (size)
{
grub_size_t to_read = (size > GRUB_DISK_SECTOR_SIZE) ? GRUB_DISK_SECTOR_SIZE : size;
(disk->read_hook) (sector, real_offset,
((size > GRUB_DISK_SECTOR_SIZE)
? GRUB_DISK_SECTOR_SIZE
: size));
to_read);
if (grub_errno != GRUB_ERR_NONE)
goto finish;
sector++;
size -= GRUB_DISK_SECTOR_SIZE - real_offset;
size -= to_read - real_offset;
real_offset = 0;
}