summaryrefslogtreecommitdiffstats
path: root/src/core/hle/service
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2021-02-13 11:30:33 +0100
committerbunnei <bunneidev@gmail.com>2021-02-14 05:11:26 +0100
commitd25011c92fe4ab7bf00e7273a3a4daa9b9d05a2b (patch)
treefba75fc3b44687d6c8e26cc2bd9d3c3bcf37c00b /src/core/hle/service
parentMerge pull request #5925 from ReinUsesLisp/resource-pool-clean (diff)
downloadyuzu-d25011c92fe4ab7bf00e7273a3a4daa9b9d05a2b.tar
yuzu-d25011c92fe4ab7bf00e7273a3a4daa9b9d05a2b.tar.gz
yuzu-d25011c92fe4ab7bf00e7273a3a4daa9b9d05a2b.tar.bz2
yuzu-d25011c92fe4ab7bf00e7273a3a4daa9b9d05a2b.tar.lz
yuzu-d25011c92fe4ab7bf00e7273a3a4daa9b9d05a2b.tar.xz
yuzu-d25011c92fe4ab7bf00e7273a3a4daa9b9d05a2b.tar.zst
yuzu-d25011c92fe4ab7bf00e7273a3a4daa9b9d05a2b.zip
Diffstat (limited to 'src/core/hle/service')
-rw-r--r--src/core/hle/service/am/am.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp
index bb77c2569..8e1fe9438 100644
--- a/src/core/hle/service/am/am.cpp
+++ b/src/core/hle/service/am/am.cpp
@@ -1047,20 +1047,21 @@ void IStorageAccessor::Write(Kernel::HLERequestContext& ctx) {
const u64 offset{rp.Pop<u64>()};
const std::vector<u8> data{ctx.ReadBuffer()};
+ const std::size_t size{std::min(data.size(), backing.GetSize() - offset)};
- LOG_DEBUG(Service_AM, "called, offset={}, size={}", offset, data.size());
+ LOG_DEBUG(Service_AM, "called, offset={}, size={}", offset, size);
- if (data.size() > backing.GetSize() - offset) {
+ if (offset > backing.GetSize()) {
LOG_ERROR(Service_AM,
"offset is out of bounds, backing_buffer_sz={}, data_size={}, offset={}",
- backing.GetSize(), data.size(), offset);
+ backing.GetSize(), size, offset);
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ERR_SIZE_OUT_OF_BOUNDS);
return;
}
- std::memcpy(backing.GetData().data() + offset, data.data(), data.size());
+ std::memcpy(backing.GetData().data() + offset, data.data(), size);
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(RESULT_SUCCESS);
@@ -1070,11 +1071,11 @@ void IStorageAccessor::Read(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};
const u64 offset{rp.Pop<u64>()};
- const std::size_t size{ctx.GetWriteBufferSize()};
+ const std::size_t size{std::min(ctx.GetWriteBufferSize(), backing.GetSize() - offset)};
LOG_DEBUG(Service_AM, "called, offset={}, size={}", offset, size);
- if (size > backing.GetSize() - offset) {
+ if (offset > backing.GetSize()) {
LOG_ERROR(Service_AM, "offset is out of bounds, backing_buffer_sz={}, size={}, offset={}",
backing.GetSize(), size, offset);