Skip to content

Commit

Permalink
[iso] work around ISOs that use broken symbolic links for UEFI bootlo…
Browse files Browse the repository at this point in the history
…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
pbatard committed Jan 16, 2024
1 parent ae6732c commit 710bfe7
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 9 deletions.
26 changes: 23 additions & 3 deletions src/iso.c
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 <pete@akeo.ie>
* Copyright © 2011-2024 Pete Batard <pete@akeo.ie>
* Based on libcdio's iso & udf samples:
* Copyright © 2003-2014 Rocky Bernstein <rocky@gnu.org>
*
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/rufus.h
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 <pete@akeo.ie>
* Copyright © 2011-2024 Pete Batard <pete@akeo.ie>
*
* 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
Expand Down
10 changes: 5 additions & 5 deletions src/rufus.rc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
IDD_DIALOG DIALOGEX 12, 12, 232, 326
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_ACCEPTFILES
CAPTION "Rufus 4.4.2100"
CAPTION "Rufus 4.4.2101"
FONT 9, "Segoe UI Symbol", 400, 0, 0x0
BEGIN
LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP
Expand Down Expand Up @@ -392,8 +392,8 @@ END
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION 4,4,2100,0
PRODUCTVERSION 4,4,2100,0
FILEVERSION 4,4,2101,0
PRODUCTVERSION 4,4,2101,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
Expand All @@ -411,13 +411,13 @@ BEGIN
VALUE "Comments", "https://rufus.ie"
VALUE "CompanyName", "Akeo Consulting"
VALUE "FileDescription", "Rufus"
VALUE "FileVersion", "4.4.2100"
VALUE "FileVersion", "4.4.2101"
VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "� 2011-2024 Pete Batard (GPL v3)"
VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html"
VALUE "OriginalFilename", "rufus-4.4.exe"
VALUE "ProductName", "Rufus"
VALUE "ProductVersion", "4.4.2100"
VALUE "ProductVersion", "4.4.2101"
END
END
BLOCK "VarFileInfo"
Expand Down

0 comments on commit 710bfe7

Please sign in to comment.