From 2db0e93f73a4b103bfec469b8ff02edce11399de Mon Sep 17 00:00:00 2001 From: sfan5 Date: Thu, 15 Aug 2019 16:11:01 +0200 Subject: network: Stricter handling of split packets --- src/network/connection.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'src/network/connection.cpp') 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 IncomingSplitBuffer::insert(const BufferedPacket &p, bool relia << std::endl; return SharedBuffer(); } + if (chunk_num >= chunk_count) { + errorstream << "IncomingSplitBuffer::insert(): chunk_num=" << chunk_num + << " >= chunk_count=" << chunk_count << std::endl; + return SharedBuffer(); + } // Add if doesn't exist if (m_buf.find(seqnum) == m_buf.end()) { @@ -425,10 +430,12 @@ SharedBuffer 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="<chunk_count - <chunk_count) { + errorstream << "IncomingSplitBuffer::insert(): chunk_count=" + << chunk_count << " != sp->chunk_count=" << sp->chunk_count + << std::endl; + return SharedBuffer(); + } if (reliable != sp->reliable) LOG(derr_con<<"Connection: WARNING: reliable="<reliable="<reliable -- cgit v1.2.3