mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-12-04 11:43:47 +01:00
Claude being too cautious. Let's just reject bad values fully.
This commit is contained in:
1 parent
3806d00e58
commit
a3e0f915af
1 file changed
+2
-2
@@ -459,11 +459,11 @@ void BlockAllocator::DoState(PointerWrap &p)
|
||||
|
||||
// A corrupt/malicious savestate could claim an enormous block count. Each
|
||||
// block needs at least sizeof(start)+sizeof(size)+sizeof(taken)+sizeof(tag)
|
||||
// bytes in the stream, so clamp to what could plausibly still be there
|
||||
// instead of always trying to allocate `count` Blocks up front.
|
||||
// bytes in the stream. Reject totally outlandish values, and also if count is now sub-zero.
|
||||
size_t maxRemainingBlocks = p.Remaining() / (sizeof(u32) + sizeof(u32) + 1 + 32);
|
||||
if (count < 0) {
|
||||
count = 0;
|
||||
p.SetError(PointerWrap::ERROR_FAILURE);
|
||||
} else if ((size_t)count > maxRemainingBlocks) {
|
||||
count = (int)maxRemainingBlocks;
|
||||
p.SetError(PointerWrap::ERROR_FAILURE);
|
||||
|
||||
Reference in new issue
Block a user