-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[iso] work around ISOs that use broken symbolic links for UEFI bootlo…
…aders * Per linuxmint/linuxmint#622 some ISOs may have a /EFI/boot/bootx64.efi that is a symbolic to a nonexisting file. * This is originally due to a Debian bug that was fixed in: https://salsa.debian.org/live-team/live-build/-/commit/5bff71fea2dd54adcd6c428d3f1981734079a2f7 * Work around this by trying to extract a working bootx64.efi from the El-Torito image. * Also improve DumpFatDir() to not replace already existing files.
- Loading branch information
Showing
3 changed files
with
29 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/* | ||
* Rufus: The Reliable USB Formatting Utility | ||
* ISO file extraction | ||
* Copyright © 2011-2023 Pete Batard <[email protected]> | ||
* Copyright © 2011-2024 Pete Batard <[email protected]> | ||
* Based on libcdio's iso & udf samples: | ||
* Copyright © 2003-2014 Rocky Bernstein <[email protected]> | ||
* | ||
|
@@ -292,6 +292,16 @@ static BOOL check_iso_props(const char* psz_dirname, int64_t file_length, const | |
} | ||
} | ||
} | ||
// Linux Mint Edge 21.2/Mint 21.3 have an invalid /EFI/boot/bootx64.efi | ||
// because it's a symbolic link to a file that does not exist on the media. | ||
// This is originally due to a Debian bug that was fixed in: | ||
// https://salsa.debian.org/live-team/live-build/-/commit/5bff71fea2dd54adcd6c428d3f1981734079a2f7 | ||
// Because of this, if we detect a small bootx64.efi file, we assert that it's a | ||
// broken link and try to extract a "good" version from the El-Torito image. | ||
if ((safe_stricmp(psz_basename, efi_bootname[2]) == 0) && (file_length < 100)) { | ||
img_report.has_efi |= 0x4000; | ||
static_strcpy(img_report.efi_img_path, "[BOOT]/1-Boot-NoEmul.img"); | ||
} | ||
} | ||
|
||
if (psz_dirname != NULL) { | ||
|
@@ -1277,8 +1287,16 @@ BOOL ExtractISO(const char* src_iso, const char* dest_dir, BOOL scan) | |
SendMessage(hMainDialog, UM_PROGRESS_EXIT, 0, 0); | ||
} else { | ||
// Solus and other ISOs only provide EFI boot files in a FAT efi.img | ||
if (img_report.has_efi == 0x8000) | ||
// Also work around ISOs that have a borked symbolic link for bootx64.efi. | ||
// See https://github.com/linuxmint/linuxmint/issues/622. | ||
if (img_report.has_efi & 0xc000) { | ||
if (img_report.has_efi & 0x4000) { | ||
uprintf("Broken UEFI bootloader detected - Applying workaround:"); | ||
static_sprintf(path, "%s\\EFI\\boot\\bootx64.efi", dest_dir); | ||
DeleteFileU(path); | ||
} | ||
DumpFatDir(dest_dir, 0); | ||
} | ||
if (HAS_SYSLINUX(img_report)) { | ||
static_sprintf(path, "%s\\syslinux.cfg", dest_dir); | ||
// Create a /syslinux.cfg (if none exists) that points to the existing isolinux cfg | ||
|
@@ -1463,6 +1481,8 @@ int64_t ExtractISOFile(const char* iso, const char* iso_file, const char* dest_f | |
|
||
out: | ||
safe_closehandle(file_handle); | ||
if (r == 0) | ||
DeleteFileU(dest_file); | ||
iso9660_stat_free(p_statbuf); | ||
udf_dirent_free(p_udf_root); | ||
udf_dirent_free(p_udf_file); | ||
|
@@ -1727,7 +1747,7 @@ BOOL DumpFatDir(const char* path, int32_t cluster) | |
} | ||
if (!DumpFatDir(target, dirpos.cluster)) | ||
goto out; | ||
} else { | ||
} else if (!PathFileExistsU(target)) { | ||
// Need to figure out if it's a .conf file (Damn you Solus!!) | ||
EXTRACT_PROPS props = { 0 }; | ||
size_t len = strlen(name); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/* | ||
* Rufus: The Reliable USB Formatting Utility | ||
* Copyright © 2011-2023 Pete Batard <[email protected]> | ||
* Copyright © 2011-2024 Pete Batard <[email protected]> | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters