From b81b440a20b79b348232901d3583ef9beadf6fe7 Mon Sep 17 00:00:00 2001 From: AJIOB Date: Mon, 24 Jul 2023 16:26:59 +0300 Subject: [PATCH] [uefi] fix search for bootloaders in FAT images that have an 'EFI' volume label * Per https://en.wikipedia.org/wiki/Design_of_the_FAT_file_system#Directory_entry it is possible to have a FAT directory entry with a 'EFI' volume label alongside with a 'EFI' subdirectory. * If that happens, then the current Syslinux libfat_searchdir() code may treat the 'EFI' volume label as an empty subdirectory and say that there are no bootloaders, even if the 'EFI\Boot\Boot###.efi' binaries really do exist. * Fix this by filtering out entries with the 'volume label' attribute (0x08). * For good measure, also filter out entries with the 'device' attribute (0x40), as it is technically possible to create a 'EFI' device leading to the same issue. * Closes #2288. * Closes #2289. --- src/rufus.rc | 10 +++++----- src/syslinux/libfat/searchdir.c | 3 ++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/rufus.rc b/src/rufus.rc index 652ed4eb..525436a8 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 4.2.2072" +CAPTION "Rufus 4.2.2073" FONT 9, "Segoe UI Symbol", 400, 0, 0x0 BEGIN LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP @@ -392,8 +392,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 4,2,2072,0 - PRODUCTVERSION 4,2,2072,0 + FILEVERSION 4,2,2073,0 + PRODUCTVERSION 4,2,2073,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -411,13 +411,13 @@ BEGIN VALUE "Comments", "https://rufus.ie" VALUE "CompanyName", "Akeo Consulting" VALUE "FileDescription", "Rufus" - VALUE "FileVersion", "4.2.2072" + VALUE "FileVersion", "4.2.2073" VALUE "InternalName", "Rufus" VALUE "LegalCopyright", "© 2011-2023 Pete Batard (GPL v3)" VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html" VALUE "OriginalFilename", "rufus-4.2.exe" VALUE "ProductName", "Rufus" - VALUE "ProductVersion", "4.2.2072" + VALUE "ProductVersion", "4.2.2073" END END BLOCK "VarFileInfo" diff --git a/src/syslinux/libfat/searchdir.c b/src/syslinux/libfat/searchdir.c index 4964120b..f863a13f 100644 --- a/src/syslinux/libfat/searchdir.c +++ b/src/syslinux/libfat/searchdir.c @@ -40,7 +40,8 @@ int32_t libfat_searchdir(struct libfat_filesystem *fs, int32_t dirclust, for (nent = 0; nent < LIBFAT_SECTOR_SIZE; nent += sizeof(struct fat_dirent)) { - if (!memcmp(dep->name, name, 11)) { + /* Filter out volume labels (0x08) and devices (0x40) from the search */ + if (!(dep->attribute & 0x48) && !memcmp(dep->name, name, 11)) { if (direntry) { memcpy(direntry->entry, dep, sizeof(*dep)); direntry->sector = s;