File tree 2 files changed +8
-3
lines changed
2 files changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -1577,7 +1577,7 @@ static void config_load_entries(
1577
1577
_cleanup_freepool_ CHAR8 * content = NULL ;
1578
1578
1579
1579
err = readdir_harder (entries_dir , & f , & f_size );
1580
- if (f_size == 0 || EFI_ERROR (err ))
1580
+ if (EFI_ERROR (err ) || ! f )
1581
1581
break ;
1582
1582
1583
1583
if (f -> FileName [0 ] == '.' )
@@ -2019,7 +2019,7 @@ static void config_entry_add_linux(
2019
2019
CHAR8 * key , * value ;
2020
2020
2021
2021
err = readdir_harder (linux_dir , & f , & f_size );
2022
- if (f_size == 0 || EFI_ERROR (err ))
2022
+ if (EFI_ERROR (err ) || ! f )
2023
2023
break ;
2024
2024
2025
2025
if (f -> FileName [0 ] == '.' )
Original file line number Diff line number Diff line change @@ -592,7 +592,12 @@ EFI_STATUS readdir_harder(
592
592
* the specified buffer needs to be freed by caller, after final use. */
593
593
594
594
if (!* buffer ) {
595
- sz = offsetof(EFI_FILE_INFO , FileName ) /* + 256 */ ;
595
+ /* Some broken firmware violates the EFI spec by still advancing the readdir
596
+ * position when returning EFI_BUFFER_TOO_SMALL, effectively skipping over any files when
597
+ * the buffer was too small. Therefore, start with a buffer that should handle FAT32 max
598
+ * file name length.
599
+ * As a side effect, most readdir_harder() calls will now be slightly faster. */
600
+ sz = sizeof (EFI_FILE_INFO ) + 256 * sizeof (CHAR16 );
596
601
* buffer = xallocate_pool (sz );
597
602
* buffer_size = sz ;
598
603
} else
You can’t perform that action at this time.
0 commit comments