[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.
This commit is contained in:
AJIOB 2023-07-24 16:26:59 +03:00 committed by Pete Batard
parent 64e85ed09a
commit b81b440a20
No known key found for this signature in database
GPG Key ID: 38E0CF5E69EDD671
2 changed files with 7 additions and 6 deletions

View File

@ -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"

View File

@ -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;