Skip to content

Commit 9dfbece

Browse files
committed
NITWORK/RFC: Fix missing check of too big uncompressed datas and fix rfc
PATCH
1 parent 22d3e79 commit 9dfbece

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

docs/network/rfc/RFC.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,9 @@ Table of Contents
142142
143143
2. Network Packet Global Structure
144144
145-
The packet are send compressed thanks to zstd library over the network
146-
with the UDP protocol. And the packet are decompressed thanks to zstd
147-
when received.
145+
The packets are compressed using the zstd library before being sent over
146+
the network using the UDP protocol. Upon receipt, the packets are
147+
decompressed using the zstd library
148148
To add some better reliability, each packet sent has a header with some
149149
information about all the packets received.
150150

src/Nitwork/Zstd.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ namespace Nitwork {
2222
if (!std::is_standard_layout_v<T> || !std::is_trivial_v<T>) {
2323
throw std::runtime_error("ZSTD: Data must be POD");
2424
}
25+
if (sizeof(T) > ZSTD_compressBound(sizeof(T))) {
26+
throw std::runtime_error("ZSTD: Input data is too large");
27+
}
2528
size_t const compressedSize = ZSTD_compressBound(sizeof(T));
2629
std::vector<char> compressedData(compressedSize);
2730
size_t const result = ZSTD_compress(

0 commit comments

Comments
 (0)