From 127008a27458ccf0fd0bc4bccc0aab492b4f3f1a Mon Sep 17 00:00:00 2001 From: aspargas2 Date: Wed, 10 Jun 2020 03:53:24 -0400 Subject: [PATCH] fix oversight in AddBDRIEntry this would cause an uninitialized u64 to be used for the entry size in certain circumstances --- arm9/source/game/bdri.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arm9/source/game/bdri.c b/arm9/source/game/bdri.c index d18fb2f..7517def 100644 --- a/arm9/source/game/bdri.c +++ b/arm9/source/game/bdri.c @@ -479,8 +479,8 @@ static u32 AddBDRIEntry(const BDRIFsHeader* fs_header, const u32 fs_header_offse u32 bytes_written = 0, fat_index_write = fat_index; - while (bytes_written < file_entry.size) { // Write the full entry, walking the FAT node chain - // Can't assume contiguity here, because we might be replacing an existing entry + while (bytes_written < size) { // Write the full entry, walking the FAT node chain + // Can't assume contiguity here, because we might be replacing an existing entry u32 write_start = fat_index_write - 1; // Data region block index u32 write_count = 0; @@ -506,7 +506,7 @@ static u32 AddBDRIEntry(const BDRIFsHeader* fs_header, const u32 fs_header_offse fat_index_write = next_index; - u32 btw = min(file_entry.size - bytes_written, write_count * fs_header->data_block_size); + u32 btw = min(size - bytes_written, write_count * fs_header->data_block_size); if (BDRIWrite(data_offset + write_start * fs_header->data_block_size, btw, entry + bytes_written) != FR_OK) return 1;