From a8f3c6c5721c5d7e9327361f11c301bf2cdc0719 Mon Sep 17 00:00:00 2001 From: Pete Batard Date: Fri, 11 Sep 2020 22:42:20 +0100 Subject: [PATCH] [iso] fix detection of GRUB version * Commit 77d319267f869d0d9eb9ac5a831164add8a5aa8d broke lookup of ISO filenames since iso9660_open() enabled the Rock Ridge extensions by default, despite using ISO_EXTENSION_NONE for the internal call, and we addressed a FIXME related to this. * This resulted in Rufus not being able to lookup 'boot/grub/i386-pc/normal.mod' to parse GRUB's version, since without Rock Ridge, 'i386-pc/' is unable to match the ISO-9660 'I386_PC/' dir. * Closes #1573 and addresses part of #1616. * Also fix a MinGW compilation warning. --- src/drive.c | 2 +- src/iso.c | 14 ++++++++++---- src/rufus.h | 1 - src/rufus.rc | 10 +++++----- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/drive.c b/src/drive.c index 783c8208..2ca6405e 100644 --- a/src/drive.c +++ b/src/drive.c @@ -406,7 +406,7 @@ char* AltGetLogicalName(DWORD DriveIndex, uint64_t PartitionOffset, BOOL bKeepTr static_strcpy(volume_name, groot_name); if (!QueryDosDeviceA(path, &volume_name[groot_len], (DWORD)(MAX_PATH - groot_len)) || (strlen(volume_name) < 20)) { suprintf("Could not find a DOS volume name for '%s': %s", path, WindowsErrorString()); - goto out; + goto out; } else if (bKeepTrailingBackslash) { static_strcat(volume_name, "\\"); } diff --git a/src/iso.c b/src/iso.c index 030f12d0..d23ad790 100644 --- a/src/iso.c +++ b/src/iso.c @@ -59,6 +59,10 @@ #define S_IFLNK 0xA000 #define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK) +// Set the iso_open_ext() extension mask according to our global options +#define ISO_EXTENSION_MASK (ISO_EXTENSION_ALL & (enable_joliet ? ISO_EXTENSION_ALL : ~ISO_EXTENSION_JOLIET) & \ + (enable_rockridge ? ISO_EXTENSION_ALL : ~ISO_EXTENSION_ROCK_RIDGE)) + // Needed for UDF ISO access CdIo_t* cdio_open (const char* psz_source, driver_id_t driver_id) {return NULL;} void cdio_destroy (CdIo_t* p_cdio) {} @@ -1181,7 +1185,9 @@ int64_t ExtractISOFile(const char* iso, const char* iso_file, const char* dest_f goto out; try_iso: - p_iso = iso9660_open(iso); + // Make sure to enable extensions, else we may not match the name of the file we are looking + // for since Rock Ridge may be needed to translate something like 'I386_PC' into 'i386-pc'... + p_iso = iso9660_open_ext(iso, ISO_EXTENSION_MASK); if (p_iso == NULL) { uprintf("Unable to open image '%s'", iso); goto out; @@ -1266,7 +1272,7 @@ uint32_t GetInstallWimVersion(const char* iso) goto out; try_iso: - p_iso = iso9660_open(iso); + p_iso = iso9660_open_ext(iso, ISO_EXTENSION_MASK); if (p_iso == NULL) { uprintf("Could not open image '%s'", iso); goto out; @@ -1353,7 +1359,7 @@ BOOL HasEfiImgBootLoaders(void) if ((image_path == NULL) || !HAS_EFI_IMG(img_report)) return FALSE; - p_iso = iso9660_open(image_path); + p_iso = iso9660_open_ext(image_path, ISO_EXTENSION_MASK); if (p_iso == NULL) { uprintf("Could not open image '%s' as an ISO-9660 file system", image_path); goto out; @@ -1444,7 +1450,7 @@ BOOL DumpFatDir(const char* path, int32_t cluster) // Root dir => Perform init stuff if (image_path == NULL) return FALSE; - p_iso = iso9660_open(image_path); + p_iso = iso9660_open_ext(image_path, ISO_EXTENSION_MASK); if (p_iso == NULL) { uprintf("Could not open image '%s' as an ISO-9660 file system", image_path); goto out; diff --git a/src/rufus.h b/src/rufus.h index eb5297e5..43c3ca24 100644 --- a/src/rufus.h +++ b/src/rufus.h @@ -482,7 +482,6 @@ extern char *image_path, *fido_url; /* * Shared prototypes */ -extern uint8_t popcnt8(uint8_t val); extern void GetWindowsVersion(void); extern BOOL is_x64(void); extern BOOL GetCpuArch(void); diff --git a/src/rufus.rc b/src/rufus.rc index 386d007b..979a34c6 100644 --- a/src/rufus.rc +++ b/src/rufus.rc @@ -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 3.12.1701" +CAPTION "Rufus 3.12.1702" FONT 9, "Segoe UI Symbol", 400, 0, 0x0 BEGIN LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP @@ -395,8 +395,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 3,12,1701,0 - PRODUCTVERSION 3,12,1701,0 + FILEVERSION 3,12,1702,0 + PRODUCTVERSION 3,12,1702,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -414,13 +414,13 @@ BEGIN VALUE "Comments", "https://rufus.ie" VALUE "CompanyName", "Akeo Consulting" VALUE "FileDescription", "Rufus" - VALUE "FileVersion", "3.12.1701" + VALUE "FileVersion", "3.12.1702" VALUE "InternalName", "Rufus" VALUE "LegalCopyright", "© 2011-2020 Pete Batard (GPL v3)" VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html" VALUE "OriginalFilename", "rufus-3.12.exe" VALUE "ProductName", "Rufus" - VALUE "ProductVersion", "3.12.1701" + VALUE "ProductVersion", "3.12.1702" END END BLOCK "VarFileInfo"