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).
This commit is contained in:
Robert Millan 2010-01-04 23:30:27 +00:00
parent 4b856776a9
commit e33ace066e
3 changed files with 15 additions and 7 deletions

View 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. */