mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-15 10:54:22 -05:00
added some security checks to turtle router
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2208 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
b47762cf12
commit
3e921bb254
@ -367,29 +367,40 @@ void p3turtle::locked_closeTunnel(TurtleTunnelId tid)
|
|||||||
std::cerr << " Associated file source." << std::endl ;
|
std::cerr << " Associated file source." << std::endl ;
|
||||||
#endif
|
#endif
|
||||||
_ft_controller->removeFileSource(hash,vpid) ;
|
_ft_controller->removeFileSource(hash,vpid) ;
|
||||||
_virtual_peers.erase(_virtual_peers.find(vpid)) ;
|
|
||||||
|
|
||||||
std::vector<TurtleTunnelId>& tunnels(_incoming_file_hashes[hash].tunnels) ;
|
// Let's be cautious. Normally we should never be here without consistent information,
|
||||||
|
// but still, this happens, rarely.
|
||||||
// Remove tunnel id from it's corresponding hash. For security we
|
|
||||||
// go through the whole tab, although the tunnel id should only be listed once
|
|
||||||
// in this tab.
|
|
||||||
//
|
//
|
||||||
for(unsigned int i=0;i<tunnels.size();)
|
if(_virtual_peers.find(vpid) != _virtual_peers.end())
|
||||||
if(tunnels[i] == tid)
|
_virtual_peers.erase(_virtual_peers.find(vpid)) ;
|
||||||
{
|
|
||||||
tunnels[i] = tunnels.back() ;
|
std::map<TurtleFileHash,TurtleFileHashInfo>::iterator it(_incoming_file_hashes.find(hash)) ;
|
||||||
tunnels.pop_back() ;
|
|
||||||
}
|
if(it != _incoming_file_hashes.end())
|
||||||
else
|
{
|
||||||
++i ;
|
std::vector<TurtleTunnelId>& tunnels(it->second.tunnels) ;
|
||||||
|
|
||||||
|
// Remove tunnel id from it's corresponding hash. For security we
|
||||||
|
// go through the whole tab, although the tunnel id should only be listed once
|
||||||
|
// in this tab.
|
||||||
|
//
|
||||||
|
for(unsigned int i=0;i<tunnels.size();)
|
||||||
|
if(tunnels[i] == tid)
|
||||||
|
{
|
||||||
|
tunnels[i] = tunnels.back() ;
|
||||||
|
tunnels.pop_back() ;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
++i ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if(it->second.local_dst == mConnMgr->getOwnId()) // This is a ending tunnel. We also remove the virtual peer id
|
else if(it->second.local_dst == mConnMgr->getOwnId()) // This is a ending tunnel. We also remove the virtual peer id
|
||||||
{
|
{
|
||||||
#ifdef P3TURTLE_DEBUG
|
#ifdef P3TURTLE_DEBUG
|
||||||
std::cerr << " Tunnel is a ending point. Also removing associated outgoing hash." ;
|
std::cerr << " Tunnel is a ending point. Also removing associated outgoing hash." ;
|
||||||
#endif
|
#endif
|
||||||
_outgoing_file_hashes.erase(_outgoing_file_hashes.find(it->second.hash)) ;
|
if(_outgoing_file_hashes.find(it->second.hash) != _outgoing_file_hashes.end())
|
||||||
|
_outgoing_file_hashes.erase(_outgoing_file_hashes.find(it->second.hash)) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
_local_tunnels.erase(it) ;
|
_local_tunnels.erase(it) ;
|
||||||
|
Loading…
Reference in New Issue
Block a user