mirror of
https://github.com/pbatard/rufus.git
synced 2025-05-31 23:08:26 -04:00
[iso] fix FAT filenames being truncated on image extraction
* Needed to read 12 chars instead of stopping at 11 and therefore inserting a NUL. * Closes #2534. * Also enable detection of bootriscv64.efi and bootloongarch64.efi bootloaders from FAT images.
This commit is contained in:
parent
8d1ed44e1e
commit
3d5ab84ec1
4 changed files with 32 additions and 29 deletions
29
src/iso.c
29
src/iso.c
|
@ -1758,8 +1758,8 @@ BOOL HasEfiImgBootLoaders(void)
|
||||||
int32_t dc, c;
|
int32_t dc, c;
|
||||||
struct libfat_filesystem *lf_fs = NULL;
|
struct libfat_filesystem *lf_fs = NULL;
|
||||||
struct libfat_direntry direntry;
|
struct libfat_direntry direntry;
|
||||||
char name[12] = { 0 }, bootloader_name[32];
|
char bootloader_name[16];
|
||||||
int i, j, k;
|
int i;
|
||||||
|
|
||||||
if ((image_path == NULL) || !HAS_EFI_IMG(img_report))
|
if ((image_path == NULL) || !HAS_EFI_IMG(img_report))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -1799,24 +1799,19 @@ BOOL HasEfiImgBootLoaders(void)
|
||||||
goto out;
|
goto out;
|
||||||
dc = direntry.entry[26] + (direntry.entry[27] << 8);
|
dc = direntry.entry[26] + (direntry.entry[27] << 8);
|
||||||
|
|
||||||
for (i = 0; i < ARRAYSIZE(efi_archname); i++) {
|
for (i = 1; i < ARRAYSIZE(efi_archname); i++) {
|
||||||
static_sprintf(bootloader_name, "boot%s.efi", efi_archname[i]);
|
// We consider it unlikely that any bootri#####.efi or bootlo#####.efi files
|
||||||
// TODO: bootriscv64.efi and bootloongarch64.efi need LFN support
|
// in the /efi/boot/ subdirectory will be anything but 'bootriscv64.efi' and
|
||||||
if (strlen(bootloader_name) > 12)
|
// 'bootloongarch64.efi', so we'll use the ~1 LFN shortened names for them.
|
||||||
continue;
|
static_sprintf(bootloader_name, "BOOT%c%c%c%cEFI", efi_archname[i][0], efi_archname[i][1],
|
||||||
for (j = 0, k = 0; bootloader_name[j] != 0; j++) {
|
strlen(efi_archname[i]) > 4 ? '~' : efi_archname[i][2],
|
||||||
if (bootloader_name[j] == '.') {
|
strlen(efi_archname[i]) > 4 ? '1' : (strlen(efi_archname[i]) > 3 ? efi_archname[i][3] : ' '));
|
||||||
while (k < 8)
|
safe_strtoupper(bootloader_name);
|
||||||
name[k++] = ' ';
|
c = libfat_searchdir(lf_fs, dc, bootloader_name, &direntry);
|
||||||
} else {
|
|
||||||
name[k++] = toupper(bootloader_name[j]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
c = libfat_searchdir(lf_fs, dc, name, &direntry);
|
|
||||||
if (c > 0) {
|
if (c > 0) {
|
||||||
if (!ret)
|
if (!ret)
|
||||||
uprintf(" Detected EFI bootloader(s) (from '%s'):", img_report.efi_img_path);
|
uprintf(" Detected EFI bootloader(s) (from '%s'):", img_report.efi_img_path);
|
||||||
uprintf(" ● '%s'", bootloader_name);
|
uprintf(" ● 'boot%s.efi'", efi_archname[i]);
|
||||||
ret = TRUE;
|
ret = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -184,6 +184,7 @@ static __inline void safe_strcp(char* dst, const size_t dst_max, const char* src
|
||||||
#define safe_vsnprintf vsnprintf
|
#define safe_vsnprintf vsnprintf
|
||||||
#endif
|
#endif
|
||||||
#define safe_strtolower(str) do { if (str != NULL) CharLowerA(str); } while(0)
|
#define safe_strtolower(str) do { if (str != NULL) CharLowerA(str); } while(0)
|
||||||
|
#define safe_strtoupper(str) do { if (str != NULL) CharUpperA(str); } while(0)
|
||||||
static __inline void static_repchr(char* p, char s, char r) {
|
static __inline void static_repchr(char* p, char s, char r) {
|
||||||
if (p != NULL) while (*p != 0) { if (*p == s) *p = r; p++; }
|
if (p != NULL) while (*p != 0) { if (*p == s) *p = r; p++; }
|
||||||
}
|
}
|
||||||
|
|
10
src/rufus.rc
10
src/rufus.rc
|
@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
|
||||||
IDD_DIALOG DIALOGEX 12, 12, 232, 326
|
IDD_DIALOG DIALOGEX 12, 12, 232, 326
|
||||||
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||||
EXSTYLE WS_EX_ACCEPTFILES
|
EXSTYLE WS_EX_ACCEPTFILES
|
||||||
CAPTION "Rufus 4.7.2214"
|
CAPTION "Rufus 4.7.2215"
|
||||||
FONT 9, "Segoe UI Symbol", 400, 0, 0x0
|
FONT 9, "Segoe UI Symbol", 400, 0, 0x0
|
||||||
BEGIN
|
BEGIN
|
||||||
LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP
|
LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP
|
||||||
|
@ -399,8 +399,8 @@ END
|
||||||
//
|
//
|
||||||
|
|
||||||
VS_VERSION_INFO VERSIONINFO
|
VS_VERSION_INFO VERSIONINFO
|
||||||
FILEVERSION 4,7,2214,0
|
FILEVERSION 4,7,2215,0
|
||||||
PRODUCTVERSION 4,7,2214,0
|
PRODUCTVERSION 4,7,2215,0
|
||||||
FILEFLAGSMASK 0x3fL
|
FILEFLAGSMASK 0x3fL
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
FILEFLAGS 0x1L
|
FILEFLAGS 0x1L
|
||||||
|
@ -418,13 +418,13 @@ BEGIN
|
||||||
VALUE "Comments", "https://rufus.ie"
|
VALUE "Comments", "https://rufus.ie"
|
||||||
VALUE "CompanyName", "Akeo Consulting"
|
VALUE "CompanyName", "Akeo Consulting"
|
||||||
VALUE "FileDescription", "Rufus"
|
VALUE "FileDescription", "Rufus"
|
||||||
VALUE "FileVersion", "4.7.2214"
|
VALUE "FileVersion", "4.7.2215"
|
||||||
VALUE "InternalName", "Rufus"
|
VALUE "InternalName", "Rufus"
|
||||||
VALUE "LegalCopyright", "© 2011-2024 Pete Batard (GPL v3)"
|
VALUE "LegalCopyright", "© 2011-2024 Pete Batard (GPL v3)"
|
||||||
VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html"
|
VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html"
|
||||||
VALUE "OriginalFilename", "rufus-4.7.exe"
|
VALUE "OriginalFilename", "rufus-4.7.exe"
|
||||||
VALUE "ProductName", "Rufus"
|
VALUE "ProductName", "Rufus"
|
||||||
VALUE "ProductVersion", "4.7.2214"
|
VALUE "ProductVersion", "4.7.2215"
|
||||||
END
|
END
|
||||||
END
|
END
|
||||||
BLOCK "VarFileInfo"
|
BLOCK "VarFileInfo"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* ----------------------------------------------------------------------- *
|
/* ----------------------------------------------------------------------- *
|
||||||
*
|
*
|
||||||
* Copyright 2019 Pete Batard <pete@akeo.ie>
|
* Copyright 2019-2024 Pete Batard <pete@akeo.ie>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -19,6 +19,10 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "libfatint.h"
|
#include "libfatint.h"
|
||||||
|
|
||||||
|
#ifndef ARRAYSIZE
|
||||||
|
#define ARRAYSIZE(a) (sizeof(a) / sizeof(*(a)))
|
||||||
|
#endif
|
||||||
|
|
||||||
static struct fat_dirent* get_next_dirent(struct libfat_filesystem *fs,
|
static struct fat_dirent* get_next_dirent(struct libfat_filesystem *fs,
|
||||||
libfat_sector_t *sector, int *offset)
|
libfat_sector_t *sector, int *offset)
|
||||||
{
|
{
|
||||||
|
@ -41,12 +45,12 @@ static struct fat_dirent* get_next_dirent(struct libfat_filesystem *fs,
|
||||||
static void fill_utf16(wchar_t *name, unsigned char *entry)
|
static void fill_utf16(wchar_t *name, unsigned char *entry)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for (i=0; i<5; i++)
|
for (i = 0; i < 5; i++)
|
||||||
name[i] = read16((le16_t*)&entry[1 + 2*i]);
|
name[i] = read16((le16_t*)&entry[1 + 2 * i]);
|
||||||
for (i=5; i<11; i++)
|
for (i = 5; i < 11; i++)
|
||||||
name[i] = read16((le16_t*)&entry[4 + 2*i]);
|
name[i] = read16((le16_t*)&entry[4 + 2 * i]);
|
||||||
for (i=11; i<12; i++)
|
for (i = 11; i < 13; i++)
|
||||||
name[i] = read16((le16_t*)&entry[6 + 2*i]);
|
name[i] = read16((le16_t*)&entry[6 + 2 * i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
int libfat_dumpdir(struct libfat_filesystem *fs, libfat_dirpos_t *dp,
|
int libfat_dumpdir(struct libfat_filesystem *fs, libfat_dirpos_t *dp,
|
||||||
|
@ -94,11 +98,14 @@ int libfat_dumpdir(struct libfat_filesystem *fs, libfat_dirpos_t *dp,
|
||||||
if ((j >= 0) && (i != j - 1))
|
if ((j >= 0) && (i != j - 1))
|
||||||
return -3;
|
return -3;
|
||||||
j = i;
|
j = i;
|
||||||
|
if (i > ARRAYSIZE(di->name) - 13)
|
||||||
|
i = ARRAYSIZE(di->name) - 13;
|
||||||
fill_utf16(&di->name[13 * i], dep->name);
|
fill_utf16(&di->name[13 * i], dep->name);
|
||||||
dep = get_next_dirent(fs, &dp->sector, &dp->offset);
|
dep = get_next_dirent(fs, &dp->sector, &dp->offset);
|
||||||
if (!dep)
|
if (!dep)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
di->name[ARRAYSIZE(di->name) - 1] = 0;
|
||||||
|
|
||||||
if (di->name[0] == 0) {
|
if (di->name[0] == 0) {
|
||||||
for (i = 0, j = 0; i < 12; i++) {
|
for (i = 0, j = 0; i < 12; i++) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue