added additional checking of incoming compressed chunk map, in case the data is currupted, which might happens with a corrupted ft_transfer.cfg file.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5816 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2012-11-13 20:13:09 +00:00
parent f1d3cf102f
commit d3a3efd492

View File

@ -94,6 +94,17 @@ ChunkMap::ChunkMap(uint64_t s,bool availability)
void ChunkMap::setAvailabilityMap(const CompressedChunkMap& map)
{
// do some sanity check
//
if( (((int)_map.size()-1)>>5) >= map._map.size() )
{
std::cerr << "ChunkMap::setPeerAvailabilityMap: Compressed chunkmap received is too small or corrupted." << std::endl;
return ;
}
// copy the map
//
_file_is_complete = true ;
_total_downloaded = 0 ;