Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
dadigang
Ventoy
Commits
64748308
Commit
64748308
authored
Mar 24, 2021
by
longpanda
Browse files
Add a workaround for buggy bootloader's out-of-range access
parent
33cc1e27
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
41 additions
and
1 deletion
+41
-1
EDK2/edk2_mod/edk2-edk2-stable201911/MdeModulePkg/Application/Ventoy/VentoyProtocol.c
...le201911/MdeModulePkg/Application/Ventoy/VentoyProtocol.c
+18
-0
INSTALL/grub/grub.cfg
INSTALL/grub/grub.cfg
+3
-1
INSTALL/ventoy/ipxe.krn
INSTALL/ventoy/ipxe.krn
+0
-0
IPXE/ipxe_mod_code/ipxe-3fe683e/src/arch/x86/core/ventoy_vdisk.c
...xe_mod_code/ipxe-3fe683e/src/arch/x86/core/ventoy_vdisk.c
+20
-0
No files found.
EDK2/edk2_mod/edk2-edk2-stable201911/MdeModulePkg/Application/Ventoy/VentoyProtocol.c
View file @
64748308
...
...
@@ -438,6 +438,8 @@ EFI_STATUS EFIAPI ventoy_block_io_read
UINT32
j
=
0
;
UINT32
lbacount
=
0
;
UINT32
secNum
=
0
;
UINT32
TmpNum
=
0
;
UINT64
VirtSec
=
0
;
UINT64
offset
=
0
;
EFI_LBA
curlba
=
0
;
EFI_LBA
lastlba
=
0
;
...
...
@@ -461,6 +463,22 @@ EFI_STATUS EFIAPI ventoy_block_io_read
{
return
ventoy_read_iso_sector
(
Lba
,
secNum
,
Buffer
);
}
else
if
(
offset
<
g_chain
->
real_img_size_in_bytes
)
{
TmpNum
=
(
g_chain
->
real_img_size_in_bytes
-
offset
)
/
2048
;
ventoy_read_iso_sector
(
Lba
,
TmpNum
,
Buffer
);
Lba
+=
TmpNum
;
secNum
-=
TmpNum
;
Buffer
=
(
UINT8
*
)
Buffer
+
(
g_chain
->
real_img_size_in_bytes
-
offset
);
offset
=
Lba
*
2048
;
}
VirtSec
=
g_chain
->
virt_img_size_in_bytes
/
2048
;
if
(
Lba
+
secNum
>
VirtSec
)
{
secNum
=
VirtSec
-
Lba
;
}
if
(
secNum
>
g_sector_flag_num
)
{
...
...
INSTALL/grub/grub.cfg
View file @
64748308
...
...
@@ -311,6 +311,8 @@ function distro_specify_initrd_file_phase2 {
vt_linux_specify_initrd_file /antiX/initrd.gz
elif [ -f (loop)/360Disk/initrd.gz ]; then
vt_linux_specify_initrd_file /360Disk/initrd.gz
elif [ -f (loop)/porteus/initrd.xz ]; then
vt_linux_specify_initrd_file /porteus/initrd.xz
fi
}
...
...
@@ -1030,7 +1032,7 @@ function iso_common_menuentry {
vt_parse_iso_volume "${vtoy_iso_part}${vt_chosen_path}" vt_system_id vt_volume_id vt_volume_space
if [ $vt_volume_space -ne $vt_chosen_size ]; then
vt_mod $vt_chosen_size 2048 vt_chosen_size_mod
if [
$vt_volume_space -gt $vt_chosen_size -o
$vt_chosen_size_mod -ne 0 ]; then
if [ $vt_chosen_size_mod -ne 0 ]; then
echo -e "\n $vt_volume_space $vt_chosen_size $vt_chosen_size_mod\n"
echo -e "\n The size of the iso file \"$vt_chosen_size\" is invalid. File corrupted ?\n"
echo -e " 此ISO文件的大小 \"$vt_chosen_size\" 有问题,请确认文件是否损坏。\n"
...
...
INSTALL/ventoy/ipxe.krn
View file @
64748308
No preview for this file type
IPXE/ipxe_mod_code/ipxe-3fe683e/src/arch/x86/core/ventoy_vdisk.c
View file @
64748308
...
...
@@ -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
))
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment