File tree Expand file tree Collapse file tree 2 files changed +8
-3
lines changed
Expand file tree Collapse file tree 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(
15771577 _cleanup_freepool_ CHAR8 * content = NULL ;
15781578
15791579 err = readdir_harder (entries_dir , & f , & f_size );
1580- if (f_size == 0 || EFI_ERROR (err ))
1580+ if (EFI_ERROR (err ) || ! f )
15811581 break ;
15821582
15831583 if (f -> FileName [0 ] == '.' )
@@ -2019,7 +2019,7 @@ static void config_entry_add_linux(
20192019 CHAR8 * key , * value ;
20202020
20212021 err = readdir_harder (linux_dir , & f , & f_size );
2022- if (f_size == 0 || EFI_ERROR (err ))
2022+ if (EFI_ERROR (err ) || ! f )
20232023 break ;
20242024
20252025 if (f -> FileName [0 ] == '.' )
Original file line number Diff line number Diff line change @@ -592,7 +592,12 @@ EFI_STATUS readdir_harder(
592592 * the specified buffer needs to be freed by caller, after final use. */
593593
594594 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 );
596601 * buffer = xallocate_pool (sz );
597602 * buffer_size = sz ;
598603 } else
You can’t perform that action at this time.
0 commit comments