]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
2010-01-27 Robert Millan <rmh.grub@aybabtu.com>
authorRobert Millan <rmh@aybabtu.com>
Wed, 27 Jan 2010 03:15:03 +0000 (03:15 +0000)
committerRobert Millan <rmh@aybabtu.com>
Wed, 27 Jan 2010 03:15:03 +0000 (03:15 +0000)
* 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.

ChangeLog
kern/disk.c

index 6c79d2b307841825ef4ac97f144d3a0367c5333e..e0ee80d227d8a21c8bd288aa2e65878428f974ec 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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.
index 544896f2f37a02c5e0552bfabdda6a1e82ffd72d..075838d1e5c9ee4e2585650c3b3db3522ab389f4 100644 (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;
                  }