GE dump playback: Refuse sections over 1 GB

A zstd frame doesn't always declare its size, and a small one can expand to
gigabytes, so this is the limit that keeps a crafted dump from exhausting
memory. The largest section in the 1042-dump test set is 82 MB.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Henrik RydgårdandClaude Opus 5.5 committed 2026-10-13 10:05:35 +02:00
1 parent 9c2cf98b84
commit ec76a4d56e
1 file changed
+5 -2
+5 -2
View File
@@ -17,7 +17,6 @@
#include <algorithm>
#include <climits>
#include <cstdint>
#include <cstring>
#include <functional>
#include <mutex>
@@ -1235,8 +1234,12 @@ static bool ReadCompressed(u32 fp, u64 fileSize, std::vector<T> &dest, u32 count
return false;
}
// Far beyond any real dump. A zstd frame doesn't always say how big it is, and a small one can
// expand to gigabytes, so this is what keeps a crafted one from exhausting memory.
const u64 MAX_SIZE = 1024 * 1024 * 1024;
const u64 sz = (u64)count * sizeof(T);
if (sz > SIZE_MAX) {
if (sz > MAX_SIZE) {
ERROR_LOG(Log::GeDebugger, "GE dump section too large: %llu bytes", (unsigned long long)sz);
return false;
} else if (version < 5) {
size_t declared = 0;