summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2023-06-22 06:07:08 +0200
committerGitHub <noreply@github.com>2023-06-22 06:07:08 +0200
commit8cb6b33809cee08407688d46971ec0225fee2c83 (patch)
tree348e0693851693f27ff20ec3c82d3944277705a2 /src
parentMerge pull request #10863 from lat9nq/tz-end-of-string (diff)
parentvfs_concat: verify short read (diff)
downloadyuzu-8cb6b33809cee08407688d46971ec0225fee2c83.tar
yuzu-8cb6b33809cee08407688d46971ec0225fee2c83.tar.gz
yuzu-8cb6b33809cee08407688d46971ec0225fee2c83.tar.bz2
yuzu-8cb6b33809cee08407688d46971ec0225fee2c83.tar.lz
yuzu-8cb6b33809cee08407688d46971ec0225fee2c83.tar.xz
yuzu-8cb6b33809cee08407688d46971ec0225fee2c83.tar.zst
yuzu-8cb6b33809cee08407688d46971ec0225fee2c83.zip
Diffstat (limited to 'src')
-rw-r--r--src/core/file_sys/vfs_concat.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/core/file_sys/vfs_concat.cpp b/src/core/file_sys/vfs_concat.cpp
index 853b893a1..311a59e5f 100644
--- a/src/core/file_sys/vfs_concat.cpp
+++ b/src/core/file_sys/vfs_concat.cpp
@@ -150,23 +150,29 @@ std::size_t ConcatenatedVfsFile::Read(u8* data, std::size_t length, std::size_t
while (cur_length > 0 && it != concatenation_map.end()) {
// Check if we can read the file at this position.
const auto& file = it->file;
- const u64 file_offset = it->offset;
+ const u64 map_offset = it->offset;
const u64 file_size = file->GetSize();
- if (cur_offset >= file_offset + file_size) {
+ if (cur_offset > map_offset + file_size) {
// Entirely out of bounds read.
break;
}
// Read the file at this position.
- const u64 intended_read_size = std::min<u64>(cur_length, file_size);
+ const u64 file_seek = cur_offset - map_offset;
+ const u64 intended_read_size = std::min<u64>(cur_length, file_size - file_seek);
const u64 actual_read_size =
- file->Read(data + (cur_offset - offset), intended_read_size, cur_offset - file_offset);
+ file->Read(data + (cur_offset - offset), intended_read_size, file_seek);
// Update tracking.
cur_offset += actual_read_size;
cur_length -= actual_read_size;
it++;
+
+ // If we encountered a short read, we're done.
+ if (actual_read_size < intended_read_size) {
+ break;
+ }
}
return cur_offset - offset;