]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
2010-01-04 Robert Millan <rmh.grub@aybabtu.com>
authorRobert Millan <rmh@aybabtu.com>
Mon, 4 Jan 2010 23:30:27 +0000 (23:30 +0000)
committerRobert Millan <rmh@aybabtu.com>
Mon, 4 Jan 2010 23:30:27 +0000 (23:30 +0000)
* disk/i386/pc/biosdisk.c (grub_biosdisk_rw): Use ALIGN_UP macro
instead of manual alignment.
* kern/disk.c (grub_disk_read): Remove grub_dprintf call (excessively
verbose).  Avoid attempts to read past end of the device
(grub_disk_adjust_range() guarantees that we can read `size' bytes,
but GRUB_DISK_CACHE_SIZE may exceed that).

ChangeLog
disk/i386/pc/biosdisk.c
kern/disk.c

index 0bcb062fb0e72348efbef5b1e0c7a1f8c60eff7b..df0eaad3425a440c4e28d21bd43a9ab2dfbbd357 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2010-01-04  Robert Millan  <rmh.grub@aybabtu.com>
+
+       * disk/i386/pc/biosdisk.c (grub_biosdisk_rw): Use ALIGN_UP macro
+       instead of manual alignment.
+       * kern/disk.c (grub_disk_read): Remove grub_dprintf call (excessively
+       verbose).  Avoid attempts to read past end of the device
+       (grub_disk_adjust_range() guarantees that we can read `size' bytes,
+       but GRUB_DISK_CACHE_SIZE may exceed that).
+
 2010-01-04  Robert Millan  <rmh.grub@aybabtu.com>
 
        * commands/crc.c (grub_cmd_crc): Abort on read errors.
index 19ee3f981181d6413ceb3cf0f761f200bf2c7f92..5f04ecc1ebd869fde802ab2ffa6822780a3b6602 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  GRUB  --  GRand Unified Bootloader
- *  Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009  Free Software Foundation, Inc.
+ *  Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010  Free Software Foundation, Inc.
  *
  *  GRUB is free software: you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -222,7 +222,7 @@ grub_biosdisk_rw (int cmd, grub_disk_t disk,
          if (cmd)
            return grub_error (GRUB_ERR_WRITE_ERROR, "can\'t write to cdrom");
 
-         dap->blocks = (dap->blocks + 3) >> 2;
+         dap->blocks = ALIGN_UP (dap->blocks, 4) >> 2;
          dap->block >>= 2;
 
          for (i = 0; i < GRUB_BIOSDISK_CDROM_RETRY_COUNT; i++)
index 1f10c873176970ae4c19f37b1509535771a499f7..544896f2f37a02c5e0552bfabdda6a1e82ffd72d 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  GRUB  --  GRand Unified Bootloader
- *  Copyright (C) 2002,2003,2004,2006,2007,2008,2009  Free Software Foundation, Inc.
+ *  Copyright (C) 2002,2003,2004,2006,2007,2008,2009,2010  Free Software Foundation, Inc.
  *
  *  GRUB is free software: you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -386,8 +386,6 @@ grub_disk_read (grub_disk_t disk, grub_disk_addr_t sector,
   char *tmp_buf;
   unsigned real_offset;
 
-  grub_dprintf ("disk", "Reading `%s'...\n", disk->name);
-
   /* First of all, check if the region is within the disk.  */
   if (grub_disk_adjust_range (disk, &sector, &offset, size) != GRUB_ERR_NONE)
     {
@@ -432,8 +430,9 @@ grub_disk_read (grub_disk_t disk, grub_disk_addr_t sector,
       else
        {
          /* Otherwise read data from the disk actually.  */
-         if ((disk->dev->read) (disk, start_sector,
-                                GRUB_DISK_CACHE_SIZE, tmp_buf)
+         if (start_sector + GRUB_DISK_CACHE_SIZE > disk->total_sectors
+             || (disk->dev->read) (disk, start_sector,
+                                   GRUB_DISK_CACHE_SIZE, tmp_buf)
              != GRUB_ERR_NONE)
            {
              /* Uggh... Failed. Instead, just read necessary data.  */