From e232dcb0a369fd5d729f47209a9827ccddd4bba3 Mon Sep 17 00:00:00 2001 From: csoler Date: Sun, 19 Apr 2015 15:04:24 +0000 Subject: [PATCH] globally prevent chunk corruption and sendign of enormous messages git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@8142 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- libretroshare/src/grouter/p3grouter.cc | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/libretroshare/src/grouter/p3grouter.cc b/libretroshare/src/grouter/p3grouter.cc index 4af3305f6..863186057 100644 --- a/libretroshare/src/grouter/p3grouter.cc +++ b/libretroshare/src/grouter/p3grouter.cc @@ -604,10 +604,23 @@ void GRouterTunnelInfo::addVirtualPeer(const TurtleVirtualPeerId& vpid) if(first_tunnel_ok_TS == 0) first_tunnel_ok_TS = now ; last_tunnel_ok_TS = now ; } + RsGRouterAbstractMsgItem *GRouterDataInfo::addDataChunk(RsGRouterTransactionChunkItem *chunk) { last_activity_TS = time(NULL) ; + // perform some checking + + if(chunk->total_size > MAX_GROUTER_DATA_SIZE + 10000 || chunk->chunk_size > chunk->total_size || chunk->chunk_start >= chunk->total_size) + { + std::cerr << " ERROR: chunk size is unconsistent, or too large: size=" << chunk->chunk_size << ", start=" << chunk->chunk_start << ", total size=" << chunk->total_size << ". Chunk will be dropped. Data pipe will be reset." << std::endl; + clear() ; + delete chunk ; + return NULL ; + } + + // now add that chunk. + if(incoming_data_buffer == NULL) { if(chunk->chunk_start != 0)