1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Add limit parameter to decompressZlib

This can prevent untrusted data, such as sent over the network,
from consuming all memory with a specially crafted payload.
This commit is contained in:
Ben Deutsch 2018-01-30 22:12:40 +01:00 committed by sfan5
parent 1116918dbb
commit 2b3490db1f
3 changed files with 81 additions and 4 deletions

View file

@ -87,7 +87,7 @@ inline bool ser_ver_supported(s32 v) {
void compressZlib(const u8 *data, size_t data_size, std::ostream &os, int level = -1);
void compressZlib(const std::string &data, std::ostream &os, int level = -1);
void decompressZlib(std::istream &is, std::ostream &os);
void decompressZlib(std::istream &is, std::ostream &os, size_t limit = 0);
// These choose between zlib and a self-made one according to version
void compress(const SharedBuffer<u8> &data, std::ostream &os, u8 version);