Fixed a cache collision bug. Thanks guufy1 for bugreport and test

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2011-06-23 09:39:12 +02:00
parent 77ba5392d0
commit 2df2e89fee

View file

@ -544,6 +544,17 @@ grub_disk_read (grub_disk_t disk, grub_disk_addr_t sector,
break;
}
if (data)
{
grub_memcpy ((char *) buf
+ (agglomerate << (GRUB_DISK_CACHE_BITS
+ GRUB_DISK_SECTOR_BITS)),
data, GRUB_DISK_CACHE_SIZE << GRUB_DISK_SECTOR_BITS);
grub_disk_cache_unlock (disk->dev->id, disk->id,
sector + (agglomerate
<< GRUB_DISK_CACHE_BITS));
}
if (agglomerate)
{
grub_disk_addr_t i;
@ -571,14 +582,9 @@ grub_disk_read (grub_disk_t disk, grub_disk_addr_t sector,
if (data)
{
grub_memcpy (buf, data,
GRUB_DISK_CACHE_SIZE << GRUB_DISK_SECTOR_BITS);
sector += GRUB_DISK_CACHE_SIZE;
buf = (char *) buf + (GRUB_DISK_CACHE_SIZE << GRUB_DISK_SECTOR_BITS);
size -= (GRUB_DISK_CACHE_SIZE << GRUB_DISK_SECTOR_BITS);
grub_disk_cache_unlock (disk->dev->id, disk->id,
sector + (agglomerate
<< GRUB_DISK_CACHE_BITS));
}
}