diff options
| author | Admiral H. Curtiss <pikachu025@gmail.com> | 2022-04-18 04:13:25 +0200 |
|---|---|---|
| committer | Admiral H. Curtiss <pikachu025@gmail.com> | 2022-04-18 23:48:00 +0200 |
| commit | ef760ee012a1a7a9d8997fecce4f0c9a7122e1bd (patch) | |
| tree | 1e97fada9f3c2a759a5d6b78353fee2ad051385b /Source/Core/UICommon/GameFileCache.cpp | |
| parent | 853cf4f8181dd0162e81ebcd61331d8765d089ca (diff) | |
Common/PointerWrap: Prevent reads/writes past the end of the buffer.
Diffstat (limited to 'Source/Core/UICommon/GameFileCache.cpp')
| -rw-r--r-- | Source/Core/UICommon/GameFileCache.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/Source/Core/UICommon/GameFileCache.cpp b/Source/Core/UICommon/GameFileCache.cpp index 1040c24b2f..a41c07553c 100644 --- a/Source/Core/UICommon/GameFileCache.cpp +++ b/Source/Core/UICommon/GameFileCache.cpp @@ -230,14 +230,14 @@ bool GameFileCache::SyncCacheFile(bool save) { // Measure the size of the buffer. u8* ptr = nullptr; - PointerWrap p(&ptr, PointerWrap::MODE_MEASURE); - DoState(&p); + PointerWrap p_measure(&ptr, 0, PointerWrap::MODE_MEASURE); + DoState(&p_measure); const size_t buffer_size = reinterpret_cast<size_t>(ptr); // Then actually do the write. std::vector<u8> buffer(buffer_size); - ptr = &buffer[0]; - p.SetMode(PointerWrap::MODE_WRITE); + ptr = buffer.data(); + PointerWrap p(&ptr, buffer_size, PointerWrap::MODE_WRITE); DoState(&p, buffer_size); if (f.WriteBytes(buffer.data(), buffer.size())) success = true; @@ -248,7 +248,7 @@ bool GameFileCache::SyncCacheFile(bool save) if (!buffer.empty() && f.ReadBytes(buffer.data(), buffer.size())) { u8* ptr = buffer.data(); - PointerWrap p(&ptr, PointerWrap::MODE_READ); + PointerWrap p(&ptr, buffer.size(), PointerWrap::MODE_READ); DoState(&p, buffer.size()); if (p.GetMode() == PointerWrap::MODE_READ) success = true; |
