Skip to content

Commit 710bfe7

Browse files
committed
[iso] work around ISOs that use broken symbolic links for UEFI bootloaders
* 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.
1 parent ae6732c commit 710bfe7

File tree

3 files changed

+29
-9
lines changed

3 files changed

+29
-9
lines changed

src/iso.c

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* Rufus: The Reliable USB Formatting Utility
33
* ISO file extraction
4-
* Copyright © 2011-2023 Pete Batard <pete@akeo.ie>
4+
* Copyright © 2011-2024 Pete Batard <pete@akeo.ie>
55
* Based on libcdio's iso & udf samples:
66
* Copyright © 2003-2014 Rocky Bernstein <rocky@gnu.org>
77
*
@@ -292,6 +292,16 @@ static BOOL check_iso_props(const char* psz_dirname, int64_t file_length, const
292292
}
293293
}
294294
}
295+
// Linux Mint Edge 21.2/Mint 21.3 have an invalid /EFI/boot/bootx64.efi
296+
// because it's a symbolic link to a file that does not exist on the media.
297+
// This is originally due to a Debian bug that was fixed in:
298+
// https://salsa.debian.org/live-team/live-build/-/commit/5bff71fea2dd54adcd6c428d3f1981734079a2f7
299+
// Because of this, if we detect a small bootx64.efi file, we assert that it's a
300+
// broken link and try to extract a "good" version from the El-Torito image.
301+
if ((safe_stricmp(psz_basename, efi_bootname[2]) == 0) && (file_length < 100)) {
302+
img_report.has_efi |= 0x4000;
303+
static_strcpy(img_report.efi_img_path, "[BOOT]/1-Boot-NoEmul.img");
304+
}
295305
}
296306

297307
if (psz_dirname != NULL) {
@@ -1277,8 +1287,16 @@ BOOL ExtractISO(const char* src_iso, const char* dest_dir, BOOL scan)
12771287
SendMessage(hMainDialog, UM_PROGRESS_EXIT, 0, 0);
12781288
} else {
12791289
// Solus and other ISOs only provide EFI boot files in a FAT efi.img
1280-
if (img_report.has_efi == 0x8000)
1290+
// Also work around ISOs that have a borked symbolic link for bootx64.efi.
1291+
// See https://github.com/linuxmint/linuxmint/issues/622.
1292+
if (img_report.has_efi & 0xc000) {
1293+
if (img_report.has_efi & 0x4000) {
1294+
uprintf("Broken UEFI bootloader detected - Applying workaround:");
1295+
static_sprintf(path, "%s\\EFI\\boot\\bootx64.efi", dest_dir);
1296+
DeleteFileU(path);
1297+
}
12811298
DumpFatDir(dest_dir, 0);
1299+
}
12821300
if (HAS_SYSLINUX(img_report)) {
12831301
static_sprintf(path, "%s\\syslinux.cfg", dest_dir);
12841302
// 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
14631481

14641482
out:
14651483
safe_closehandle(file_handle);
1484+
if (r == 0)
1485+
DeleteFileU(dest_file);
14661486
iso9660_stat_free(p_statbuf);
14671487
udf_dirent_free(p_udf_root);
14681488
udf_dirent_free(p_udf_file);
@@ -1727,7 +1747,7 @@ BOOL DumpFatDir(const char* path, int32_t cluster)
17271747
}
17281748
if (!DumpFatDir(target, dirpos.cluster))
17291749
goto out;
1730-
} else {
1750+
} else if (!PathFileExistsU(target)) {
17311751
// Need to figure out if it's a .conf file (Damn you Solus!!)
17321752
EXTRACT_PROPS props = { 0 };
17331753
size_t len = strlen(name);

src/rufus.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Rufus: The Reliable USB Formatting Utility
3-
* Copyright © 2011-2023 Pete Batard <pete@akeo.ie>
3+
* Copyright © 2011-2024 Pete Batard <pete@akeo.ie>
44
*
55
* This program is free software: you can redistribute it and/or modify
66
* it under the terms of the GNU General Public License as published by

src/rufus.rc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
3333
IDD_DIALOG DIALOGEX 12, 12, 232, 326
3434
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
3535
EXSTYLE WS_EX_ACCEPTFILES
36-
CAPTION "Rufus 4.4.2100"
36+
CAPTION "Rufus 4.4.2101"
3737
FONT 9, "Segoe UI Symbol", 400, 0, 0x0
3838
BEGIN
3939
LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP
@@ -392,8 +392,8 @@ END
392392
//
393393

394394
VS_VERSION_INFO VERSIONINFO
395-
FILEVERSION 4,4,2100,0
396-
PRODUCTVERSION 4,4,2100,0
395+
FILEVERSION 4,4,2101,0
396+
PRODUCTVERSION 4,4,2101,0
397397
FILEFLAGSMASK 0x3fL
398398
#ifdef _DEBUG
399399
FILEFLAGS 0x1L
@@ -411,13 +411,13 @@ BEGIN
411411
VALUE "Comments", "https://rufus.ie"
412412
VALUE "CompanyName", "Akeo Consulting"
413413
VALUE "FileDescription", "Rufus"
414-
VALUE "FileVersion", "4.4.2100"
414+
VALUE "FileVersion", "4.4.2101"
415415
VALUE "InternalName", "Rufus"
416416
VALUE "LegalCopyright", "� 2011-2024 Pete Batard (GPL v3)"
417417
VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html"
418418
VALUE "OriginalFilename", "rufus-4.4.exe"
419419
VALUE "ProductName", "Rufus"
420-
VALUE "ProductVersion", "4.4.2100"
420+
VALUE "ProductVersion", "4.4.2101"
421421
END
422422
END
423423
BLOCK "VarFileInfo"

0 commit comments

Comments
 (0)