From d7583324259c0c99d9f4a545751dc109229c6f05 Mon Sep 17 00:00:00 2001 From: Subv Date: Sat, 17 Feb 2018 13:54:59 -0500 Subject: [PATCH] Parcel: Ensure we don't read past the end of the parcels in Vi. --- src/core/hle/service/vi/vi.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/core/hle/service/vi/vi.cpp b/src/core/hle/service/vi/vi.cpp index 1afd5a4fb..0aa621dfe 100644 --- a/src/core/hle/service/vi/vi.cpp +++ b/src/core/hle/service/vi/vi.cpp @@ -39,6 +39,7 @@ public: template T Read() { + ASSERT(read_index + sizeof(T) <= buffer.size()); T val; std::memcpy(&val, buffer.data() + read_index, sizeof(T)); read_index += sizeof(T); @@ -48,6 +49,7 @@ public: template T ReadUnaligned() { + ASSERT(read_index + sizeof(T) <= buffer.size()); T val; std::memcpy(&val, buffer.data() + read_index, sizeof(T)); read_index += sizeof(T); @@ -55,6 +57,7 @@ public: } std::vector ReadBlock(size_t length) { + ASSERT(read_index + length <= buffer.size()); const u8* const begin = buffer.data() + read_index; const u8* const end = begin + length; std::vector data(begin, end); @@ -97,6 +100,8 @@ public: } void Deserialize() { + ASSERT(buffer.size() > sizeof(Header)); + Header header{}; std::memcpy(&header, buffer.data(), sizeof(Header));