mirror of
https://github.com/ventoy/Ventoy.git
synced 2025-05-19 01:35:15 -04:00
Add a workaround for buggy bootloader's out-of-range access
This commit is contained in:
parent
33cc1e271a
commit
64748308a3
4 changed files with 41 additions and 1 deletions
|
@ -386,6 +386,7 @@ int ventoy_vdisk_read(struct san_device *sandev, uint64_t lba, unsigned int coun
|
|||
uint32_t lbacount = 0;
|
||||
unsigned long lastbuffer;
|
||||
uint64_t readend;
|
||||
uint64_t VirtSec;
|
||||
ventoy_virt_chunk *node;
|
||||
ventoy_sector_flag *cur_flag;
|
||||
ventoy_sector_flag *sector_flag = g_sector_flag;
|
||||
|
@ -419,6 +420,25 @@ int ventoy_vdisk_read(struct san_device *sandev, uint64_t lba, unsigned int coun
|
|||
ix86->regs.dl = sandev->drive;
|
||||
return 0;
|
||||
}
|
||||
else if ((lba * 2048) < g_chain->real_img_size_in_bytes)
|
||||
{
|
||||
/* fix for grub4dos Inconsistent data read from error */
|
||||
memset((void *)(buffer + (count - 1) * 2048), 0, 2048);
|
||||
|
||||
count = (g_chain->real_img_size_in_bytes / 2048) - lba;
|
||||
ventoy_vdisk_read_real(lba, count, buffer);
|
||||
ix86->regs.dl = sandev->drive;
|
||||
|
||||
lba += count;
|
||||
buffer += count * 2048;
|
||||
count = (readend - g_chain->real_img_size_in_bytes) / 2048;
|
||||
}
|
||||
|
||||
VirtSec = g_chain->virt_img_size_in_bytes / 2048;
|
||||
if (lba + count > VirtSec)
|
||||
{
|
||||
count = VirtSec - lba;
|
||||
}
|
||||
|
||||
if (count > sizeof(g_sector_flag))
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue