Fix File::Write() not conforming to debug header validation (#952)
Some checks are pending
citra-build / source (push) Waiting to run
citra-build / linux (appimage) (push) Waiting to run
citra-build / linux (fresh) (push) Waiting to run
citra-build / macos (arm64) (push) Waiting to run
citra-build / macos (x86_64) (push) Waiting to run
citra-build / macos-universal (push) Blocked by required conditions
citra-build / windows (msvc) (push) Waiting to run
citra-build / windows (msys2) (push) Waiting to run
citra-build / android (push) Waiting to run
citra-build / ios (push) Waiting to run
citra-format / clang-format (push) Waiting to run
citra-transifex / transifex (push) Waiting to run

This commit is contained in:
lannoene 2025-04-18 03:51:15 -07:00 committed by GitHub
parent a6782e8a13
commit de1b520498
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -169,6 +169,7 @@ void File::Write(Kernel::HLERequestContext& ctx) {
u64 offset = rp.Pop<u64>(); u64 offset = rp.Pop<u64>();
u32 length = rp.Pop<u32>(); u32 length = rp.Pop<u32>();
u32 flags = rp.Pop<u32>(); u32 flags = rp.Pop<u32>();
auto& buffer = rp.PopMappedBuffer();
LOG_TRACE(Service_FS, "Write {}: offset=0x{:x} length={}, flags=0x{:x}", GetName(), offset, LOG_TRACE(Service_FS, "Write {}: offset=0x{:x} length={}, flags=0x{:x}", GetName(), offset,
length, flags); length, flags);
@ -180,14 +181,13 @@ void File::Write(Kernel::HLERequestContext& ctx) {
if (file->subfile) { if (file->subfile) {
rb.Push(FileSys::ResultUnsupportedOpenFlags); rb.Push(FileSys::ResultUnsupportedOpenFlags);
rb.Push<u32>(0); rb.Push<u32>(0);
rb.PushMappedBuffer(rp.PopMappedBuffer()); rb.PushMappedBuffer(buffer);
return; return;
} }
bool flush = (flags & 0xFF) != 0, update_timestamp = (flags & 0xFF00) != 0; bool flush = (flags & 0xFF) != 0, update_timestamp = (flags & 0xFF00) != 0;
if (!backend->AllowsCachedReads()) { if (!backend->AllowsCachedReads()) {
std::vector<u8> data(length); std::vector<u8> data(length);
auto& buffer = rp.PopMappedBuffer();
buffer.Read(data.data(), 0, data.size()); buffer.Read(data.data(), 0, data.size());
ResultVal<std::size_t> written = ResultVal<std::size_t> written =
backend->Write(offset, data.size(), flush, update_timestamp, data.data()); backend->Write(offset, data.size(), flush, update_timestamp, data.data());
@ -223,7 +223,7 @@ void File::Write(Kernel::HLERequestContext& ctx) {
async_data->offset = offset; async_data->offset = offset;
async_data->flush = flush; async_data->flush = flush;
async_data->update_timestamp = update_timestamp; async_data->update_timestamp = update_timestamp;
async_data->buffer = &rp.PopMappedBuffer(); async_data->buffer = &buffer;
async_data->file = file; async_data->file = file;
ctx.RunAsync( ctx.RunAsync(