aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsfan5 <sfan5@live.de>2019-08-15 16:11:01 +0200
committersfan5 <sfan5@live.de>2019-08-15 20:15:22 +0200
commit2db0e93f73a4b103bfec469b8ff02edce11399de (patch)
tree3f04f8ed91fb842985183d06413397ae2c915919
parentc4491165da36db5c6a3e401cd439dbaedb65c9b6 (diff)
downloadminetest-2db0e93f73a4b103bfec469b8ff02edce11399de.tar.gz
minetest-2db0e93f73a4b103bfec469b8ff02edce11399de.tar.bz2
minetest-2db0e93f73a4b103bfec469b8ff02edce11399de.zip
network: Stricter handling of split packets
-rw-r--r--src/network/connection.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/network/connection.cpp b/src/network/connection.cpp
index 3c6cc5f3f..3ebc7c02a 100644
--- a/src/network/connection.cpp
+++ b/src/network/connection.cpp
@@ -417,6 +417,11 @@ SharedBuffer<u8> IncomingSplitBuffer::insert(const BufferedPacket &p, bool relia
<< std::endl;
return SharedBuffer<u8>();
}
+ if (chunk_num >= chunk_count) {
+ errorstream << "IncomingSplitBuffer::insert(): chunk_num=" << chunk_num
+ << " >= chunk_count=" << chunk_count << std::endl;
+ return SharedBuffer<u8>();
+ }
// Add if doesn't exist
if (m_buf.find(seqnum) == m_buf.end()) {
@@ -425,10 +430,12 @@ SharedBuffer<u8> IncomingSplitBuffer::insert(const BufferedPacket &p, bool relia
IncomingSplitPacket *sp = m_buf[seqnum];
- if (chunk_count != sp->chunk_count)
- LOG(derr_con<<"Connection: WARNING: chunk_count="<<chunk_count
- <<" != sp->chunk_count="<<sp->chunk_count
- <<std::endl);
+ if (chunk_count != sp->chunk_count) {
+ errorstream << "IncomingSplitBuffer::insert(): chunk_count="
+ << chunk_count << " != sp->chunk_count=" << sp->chunk_count
+ << std::endl;
+ return SharedBuffer<u8>();
+ }
if (reliable != sp->reliable)
LOG(derr_con<<"Connection: WARNING: reliable="<<reliable
<<" != sp->reliable="<<sp->reliable