summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Lioncash2018-07-19 09:53:35 -0400
committerGravatar Lioncash2018-07-19 09:57:48 -0400
commitd6e9b96e2f16dd7aa37e580e5c2b10c15fc82426 (patch)
tree7e444921bee8ca9922431a3bd6da6e3ff9375690 /src
parentMerge pull request #700 from bunnei/update-dynarmic (diff)
downloadyuzu-d6e9b96e2f16dd7aa37e580e5c2b10c15fc82426.tar.gz
yuzu-d6e9b96e2f16dd7aa37e580e5c2b10c15fc82426.tar.xz
yuzu-d6e9b96e2f16dd7aa37e580e5c2b10c15fc82426.zip
fsp_srv: Respect write length in Write()
Previously we were just copying the data whole-sale, even if the length was less than the total data size. This effectively makes the actual_data vector useless, which is likely not intended. Instead, amend this to only copy the given length amount of data. At the same time, we can avoid zeroing out the data before using it by passing iterators to the constructor instead of a size.
Diffstat (limited to 'src')
-rw-r--r--src/core/hle/service/filesystem/fsp_srv.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/core/hle/service/filesystem/fsp_srv.cpp b/src/core/hle/service/filesystem/fsp_srv.cpp
index 1b003bd84..e3f237c5c 100644
--- a/src/core/hle/service/filesystem/fsp_srv.cpp
+++ b/src/core/hle/service/filesystem/fsp_srv.cpp
@@ -3,6 +3,8 @@
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include <cinttypes> 5#include <cinttypes>
6#include <utility>
7
6#include "common/logging/log.h" 8#include "common/logging/log.h"
7#include "common/string_util.h" 9#include "common/string_util.h"
8#include "core/core.h" 10#include "core/core.h"
@@ -133,17 +135,16 @@ private:
133 return; 135 return;
134 } 136 }
135 137
136 std::vector<u8> data = ctx.ReadBuffer(); 138 const std::vector<u8> data = ctx.ReadBuffer();
137 std::vector<u8> actual_data(length);
138 139
139 ASSERT_MSG( 140 ASSERT_MSG(
140 data.size() <= length, 141 data.size() <= length,
141 "Attempting to write more data than requested (requested={:016X}, actual={:016X}).", 142 "Attempting to write more data than requested (requested={:016X}, actual={:016X}).",
142 length, data.size()); 143 length, data.size());
143 144
144 std::copy(data.begin(), data.end(), actual_data.begin());
145 // Write the data to the Storage backend 145 // Write the data to the Storage backend
146 auto written = backend->WriteBytes(data, offset); 146 std::vector<u8> actual_data(data.begin(), data.begin() + length);
147 const auto written = backend->WriteBytes(std::move(actual_data), offset);
147 148
148 ASSERT_MSG(written == length, 149 ASSERT_MSG(written == length,
149 "Could not write all bytes to file (requested={:016X}, actual={:016X}).", length, 150 "Could not write all bytes to file (requested={:016X}, actual={:016X}).", length,