mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-11-18 17:55:27 +00:00
fix: limit the chunks and the inflated size of an sd0 buffer
An sd0 buffer could hold any number of chunks, and each chunk grew the inflated data by a full chunk whatever it held, so the data of a chunk that was not full was followed by a gap. A buffer now holds at most 4096 chunks and inflates to at most 64 MiB, and every chunk is inflated right after the one before it. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
@@ -4,7 +4,9 @@
|
||||
#ifndef SD0_H
|
||||
#define SD0_H
|
||||
|
||||
#include <cstdint>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
@@ -23,6 +25,16 @@ public:
|
||||
*/
|
||||
static constexpr inline size_t MAX_UNCOMPRESSED_CHUNK_SIZE = 1024 * 256;
|
||||
|
||||
/**
|
||||
* @brief Max number of zlib chunks in one sd0 buffer
|
||||
*/
|
||||
static constexpr inline uint32_t MAX_CHUNKS = 4096;
|
||||
|
||||
/**
|
||||
* @brief Max size of an sd0 buffer once all of its chunks are inflated, far above the size of a model
|
||||
*/
|
||||
static constexpr inline uint32_t MAX_UNCOMPRESSED_SIZE = 64 * 1024 * 1024;
|
||||
|
||||
// Empty, for FromData
|
||||
Sd0() = default;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user