From f9ce3748032f1671e416bf322ab0ac986448e3d8 Mon Sep 17 00:00:00 2001 From: Elad <18193363+elad335@users.noreply.github.com> Date: Thu, 3 Sep 2026 19:03:22 +0300 Subject: [PATCH] SaveStates: Reject unrealistic memory allocations --- rpcs3/Emu/Cell/lv2/sys_prx.cpp | 2 +- rpcs3/util/serialization.hpp | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/rpcs3/Emu/Cell/lv2/sys_prx.cpp b/rpcs3/Emu/Cell/lv2/sys_prx.cpp index f9efd58fa73a..d12c11d31c3a 100644 --- a/rpcs3/Emu/Cell/lv2/sys_prx.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_prx.cpp @@ -324,7 +324,7 @@ std::function lv2_prx::load(utils::serial& ar) const u32 state{ar}; usz seg_count = 0; - ar.deserialize_vle(seg_count); + ar.deserialize_vle<9>(seg_count); shared_ptr prx; diff --git a/rpcs3/util/serialization.hpp b/rpcs3/util/serialization.hpp index a6e38edab338..da54981d89c1 100644 --- a/rpcs3/util/serialization.hpp +++ b/rpcs3/util/serialization.hpp @@ -206,12 +206,12 @@ namespace utils return true; } - template requires Integral + template requires Integral && (MaxBits <= sizeof(T) * 8) bool deserialize_vle(T& value) { using unsigned_type = std::make_unsigned_t; unsigned_type result{}; - constexpr u32 bit_width = sizeof(T) * 8; + constexpr u32 bit_width = MaxBits ? sizeof(T) * 8 : MaxBits; value = {}; for (u32 i = 0;; i += 7) @@ -306,7 +306,7 @@ namespace utils } usz size = 0; - if (!deserialize_vle(size)) + if (!deserialize_vle<28>(size)) { return false; } @@ -423,7 +423,7 @@ namespace utils } usz size = 0; - if (!deserialize_vle(size)) + if (!deserialize_vle<28>(size)) { return false; }