From 63eb747cdea03b9e43a39c266be24a5969c8873f Mon Sep 17 00:00:00 2001 From: Pete Batard Date: Wed, 1 Nov 2017 12:30:29 +0000 Subject: [PATCH] [iso] make the lookup for updatable .cfg file more generic * For ESET and other ISOs, such as Arch derivatives * Closes #1013 --- src/iso.c | 22 ++++++++++------------ src/parser.c | 3 ++- src/rufus.rc | 10 +++++----- 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/src/iso.c b/src/iso.c index cbecbdd5..ea9a05a7 100644 --- a/src/iso.c +++ b/src/iso.c @@ -57,9 +57,9 @@ void cdio_destroy (CdIo_t* p_cdio) {} uint32_t GetInstallWimVersion(const char* iso); typedef struct { + BOOLEAN is_cfg; BOOLEAN is_syslinux_cfg; BOOLEAN is_grub_cfg; - BOOLEAN is_arch_cfg; BOOLEAN is_old_c32[NB_OLD_C32]; } EXTRACT_PROPS; @@ -83,7 +83,6 @@ static const char* install_wim_name[] = { "install.wim", "install.swm" }; static const char* grub_dirname = "/boot/grub/i386-pc"; static const char* grub_cfg = "grub.cfg"; static const char* syslinux_cfg[] = { "isolinux.cfg", "syslinux.cfg", "extlinux.conf" }; -static const char* arch_cfg[] = { "archiso_sys.cfg", "archiso_sys32.cfg", "archiso_sys64.cfg" }; static const char* isolinux_bin[] = { "isolinux.bin", "boot.bin" }; static const char* pe_dirname[] = { "/i386", "/minint" }; static const char* pe_file[] = { "ntdetect.com", "setupldr.bin", "txtsetup.sif" }; @@ -144,11 +143,12 @@ static void log_handler (cdio_log_level_t level, const char *message) static BOOL check_iso_props(const char* psz_dirname, int64_t i_file_length, const char* psz_basename, const char* psz_fullpath, EXTRACT_PROPS *props) { - size_t i, j; + size_t i, j, len; // Check for an isolinux/syslinux config file anywhere memset(props, 0, sizeof(EXTRACT_PROPS)); for (i=0; iis_cfg = TRUE; // Required for "extlinux.conf" props->is_syslinux_cfg = TRUE; if ((scan_only) && (i == 1) && (safe_stricmp(psz_dirname, efi_dirname) == 0)) img_report.has_efi_syslinux = TRUE; @@ -161,13 +161,11 @@ static BOOL check_iso_props(const char* psz_dirname, int64_t i_file_length, cons props->is_old_c32[i] = TRUE; } - // Check for ArchLinux derivatives config files + // Check for config files that may need patching if (!scan_only) { - for (i = 0; iis_arch_cfg = TRUE; - } - } + len = safe_strlen(psz_basename); + if ((len >= 4) && safe_stricmp(&psz_basename[len-4], ".cfg") == 0) + props->is_cfg = TRUE; } // Check for GRUB artifacts @@ -276,7 +274,7 @@ static void fix_config(const char* psz_fullpath, const char* psz_path, const cha // Workaround for config files requiring an ISO label for kernel append that may be // different from our USB label. Oh, and these labels must have spaces converted to \x20. - if ((props->is_syslinux_cfg) || (props->is_grub_cfg) || (props->is_arch_cfg)) { + if (props->is_cfg) { iso_label = replace_char(img_report.label, ' ', "\\x20"); usb_label = replace_char(img_report.usb_label, ' ', "\\x20"); if ((iso_label != NULL) && (usb_label != NULL)) { @@ -468,7 +466,7 @@ static int udf_extract_files(udf_t *p_udf, udf_dirent_t *p_udf_dirent, const cha // The drawback however is with cancellation. With a large file, CloseHandle() // may take forever to complete and is not interruptible. We try to detect this. ISO_BLOCKING(safe_closehandle(file_handle)); - if (props.is_syslinux_cfg || props.is_grub_cfg || props.is_arch_cfg) + if (props.is_cfg) fix_config(psz_sanpath, psz_path, psz_basename, &props); safe_free(psz_sanpath); } @@ -614,7 +612,7 @@ static int iso_extract_files(iso9660_t* p_iso, const char *psz_path) uprintf(" Could not set timestamp: %s", WindowsErrorString()); } ISO_BLOCKING(safe_closehandle(file_handle)); - if (props.is_syslinux_cfg || props.is_grub_cfg || props.is_arch_cfg) + if (props.is_cfg) fix_config(psz_sanpath, psz_path, psz_basename, &props); safe_free(psz_sanpath); } diff --git a/src/parser.c b/src/parser.c index 9846402e..73233a6b 100644 --- a/src/parser.c +++ b/src/parser.c @@ -1131,7 +1131,8 @@ char* replace_in_token_data(const char* filename, const char* token, const char* } // Check the input file's BOM and create an output file with the same if (fread(&bom, sizeof(bom), 1, fd_in) != 1) { - uprintf("Could not read file '%s'\n", filename); + if (!feof(fd_in)) + uprintf("Could not read file '%s'\n", filename); goto out; } switch(bom) { diff --git a/src/rufus.rc b/src/rufus.rc index 174242e5..b13f55f3 100644 --- a/src/rufus.rc +++ b/src/rufus.rc @@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL IDD_DIALOG DIALOGEX 12, 12, 242, 376 STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_ACCEPTFILES -CAPTION "Rufus 2.18.1208" +CAPTION "Rufus 2.18.1209" FONT 8, "Segoe UI Symbol", 400, 0, 0x0 BEGIN LTEXT "Device",IDS_DEVICE_TXT,9,6,200,8 @@ -366,8 +366,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 2,18,1208,0 - PRODUCTVERSION 2,18,1208,0 + FILEVERSION 2,18,1209,0 + PRODUCTVERSION 2,18,1209,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -384,13 +384,13 @@ BEGIN BEGIN VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)" VALUE "FileDescription", "Rufus" - VALUE "FileVersion", "2.18.1208" + VALUE "FileVersion", "2.18.1209" VALUE "InternalName", "Rufus" VALUE "LegalCopyright", "© 2011-2017 Pete Batard (GPL v3)" VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html" VALUE "OriginalFilename", "rufus.exe" VALUE "ProductName", "Rufus" - VALUE "ProductVersion", "2.18.1208" + VALUE "ProductVersion", "2.18.1209" END END BLOCK "VarFileInfo"