fix oversight in AddBDRIEntry

this would cause an uninitialized u64 to be used for the entry size in certain circumstances
This commit is contained in:
aspargas2 2020-06-10 03:53:24 -04:00 committed by d0k3
parent 6e63fdf4bf
commit 127008a274

View File

@ -479,7 +479,7 @@ static u32 AddBDRIEntry(const BDRIFsHeader* fs_header, const u32 fs_header_offse
u32 bytes_written = 0, fat_index_write = fat_index; u32 bytes_written = 0, fat_index_write = fat_index;
while (bytes_written < file_entry.size) { // Write the full entry, walking the FAT node chain 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 // 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_start = fat_index_write - 1; // Data region block index
u32 write_count = 0; 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; 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) if (BDRIWrite(data_offset + write_start * fs_header->data_block_size, btw, entry + bytes_written) != FR_OK)
return 1; return 1;