diff options
| author | TheKodeToad <TheKodeToad@proton.me> | 2023-11-05 12:00:28 +0000 |
|---|---|---|
| committer | TheKodeToad <TheKodeToad@proton.me> | 2023-11-05 12:00:28 +0000 |
| commit | 37084afebfb09b30126f26eb64e508c5b8f9e8b6 (patch) | |
| tree | 0f77e1066fda1078158dbac25020dfebfee0a1cc /src/io/stream_reader.cpp | |
| parent | a5e8fd52b8bf4ab5d5bcc042b2a247867589985f (diff) | |
| download | Project-Tick-37084afebfb09b30126f26eb64e508c5b8f9e8b6.tar.gz Project-Tick-37084afebfb09b30126f26eb64e508c5b8f9e8b6.zip | |
Limit recursion, attempt 2
Diffstat (limited to 'src/io/stream_reader.cpp')
| -rw-r--r-- | src/io/stream_reader.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/io/stream_reader.cpp b/src/io/stream_reader.cpp index f6f30a5b49..cf0dee38e8 100644 --- a/src/io/stream_reader.cpp +++ b/src/io/stream_reader.cpp @@ -27,6 +27,8 @@ namespace nbt namespace io { +constexpr int MAX_DEPTH = 1024; + std::pair<std::string, std::unique_ptr<tag_compound>> read_compound(std::istream& is, endian::endian e) { return stream_reader(is, e).read_compound(); @@ -74,8 +76,11 @@ std::pair<std::string, std::unique_ptr<tag>> stream_reader::read_tag() std::unique_ptr<tag> stream_reader::read_payload(tag_type type) { + if (++depth > MAX_DEPTH) + throw input_error("Too deeply nested"); std::unique_ptr<tag> t = tag::create(type); t->read_payload(*this); + --depth; return t; } |
