mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-11-15 16:40:06 +00:00
Parcel: Ensure we don't read past the end of the parcels in Vi.
This commit is contained in:
parent
2662de6e52
commit
d758332425
@ -39,6 +39,7 @@ public:
|
|||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T Read() {
|
T Read() {
|
||||||
|
ASSERT(read_index + sizeof(T) <= buffer.size());
|
||||||
T val;
|
T val;
|
||||||
std::memcpy(&val, buffer.data() + read_index, sizeof(T));
|
std::memcpy(&val, buffer.data() + read_index, sizeof(T));
|
||||||
read_index += sizeof(T);
|
read_index += sizeof(T);
|
||||||
@ -48,6 +49,7 @@ public:
|
|||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T ReadUnaligned() {
|
T ReadUnaligned() {
|
||||||
|
ASSERT(read_index + sizeof(T) <= buffer.size());
|
||||||
T val;
|
T val;
|
||||||
std::memcpy(&val, buffer.data() + read_index, sizeof(T));
|
std::memcpy(&val, buffer.data() + read_index, sizeof(T));
|
||||||
read_index += sizeof(T);
|
read_index += sizeof(T);
|
||||||
@ -55,6 +57,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::vector<u8> ReadBlock(size_t length) {
|
std::vector<u8> ReadBlock(size_t length) {
|
||||||
|
ASSERT(read_index + length <= buffer.size());
|
||||||
const u8* const begin = buffer.data() + read_index;
|
const u8* const begin = buffer.data() + read_index;
|
||||||
const u8* const end = begin + length;
|
const u8* const end = begin + length;
|
||||||
std::vector<u8> data(begin, end);
|
std::vector<u8> data(begin, end);
|
||||||
@ -97,6 +100,8 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Deserialize() {
|
void Deserialize() {
|
||||||
|
ASSERT(buffer.size() > sizeof(Header));
|
||||||
|
|
||||||
Header header{};
|
Header header{};
|
||||||
std::memcpy(&header, buffer.data(), sizeof(Header));
|
std::memcpy(&header, buffer.data(), sizeof(Header));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user