fs: update IndirectStorage for 10.x, bugfixes

This commit is contained in:
Michael Scire 2020-06-25 17:36:05 -07:00
parent f594de0081
commit f197b88dd7
3 changed files with 12 additions and 3 deletions

View file

@ -133,7 +133,7 @@ namespace ams::fssystem {
virtual Result GetSize(s64 *out) override {
AMS_ASSERT(out != nullptr);
*out = this->table.GetSize();
*out = this->table.GetEnd();
return ResultSuccess();
}

View file

@ -101,7 +101,16 @@ namespace ams::fssystem {
}
if (needs_operate) {
R_TRY(func(std::addressof(this->data_storage[cur_entry.storage_index]), cur_entry.GetPhysicalOffset() + data_offset, cur_offset, cur_size));
/* Get the current data storage's size. */
s64 cur_data_storage_size;
R_TRY(this->data_storage[cur_entry.storage_index].GetSize(std::addressof(cur_data_storage_size)));
/* Ensure that we remain within range. */
const auto cur_entry_phys_offset = cur_entry.GetPhysicalOffset();
R_UNLESS(0 <= cur_entry_phys_offset && cur_entry_phys_offset <= cur_data_storage_size, fs::ResultIndirectStorageCorrupted());
R_UNLESS(cur_entry_phys_offset + data_offset + cur_size <= cur_data_storage_size, fs::ResultIndirectStorageCorrupted());
R_TRY(func(std::addressof(this->data_storage[cur_entry.storage_index]), cur_entry_phys_offset + data_offset, cur_offset, cur_size));
}
cur_offset += cur_size;

View file

@ -888,7 +888,7 @@ namespace ams::fssystem {
/* Set the storage holder's storages. */
storage->SetStorage(0, original_storage.get(), 0, original_data_size);
storage->SetStorage(1, indirect_table_storage.get(), 0, indirect_data_size);
storage->SetStorage(1, indirect_data_storage.get(), 0, indirect_data_size);
storage->Set(std::move(base_storage), std::move(original_storage), std::move(indirect_table_storage), std::move(indirect_data_storage));
/* Set the indirect storage. */