From: <arn...@us...> - 2007-12-23 20:29:59
|
Revision: 950 http://dcplusplus.svn.sourceforge.net/dcplusplus/?rev=950&view=rev Author: arnetheduck Date: 2007-12-23 12:29:57 -0800 (Sun, 23 Dec 2007) Log Message: ----------- Make bloom filters slightly more robust Modified Paths: -------------- dcplusplus/trunk/dcpp/AdcHub.cpp dcplusplus/trunk/dcpp/ShareManager.cpp Modified: dcplusplus/trunk/dcpp/AdcHub.cpp =================================================================== --- dcplusplus/trunk/dcpp/AdcHub.cpp 2007-12-23 11:04:30 UTC (rev 949) +++ dcplusplus/trunk/dcpp/AdcHub.cpp 2007-12-23 20:29:57 UTC (rev 950) @@ -489,7 +489,20 @@ ByteVector v; size_t m = Util::toUInt32(c.getParam(3)) * 8; size_t k = Util::toUInt32(tmp); - + + if(k > 8 || k < 1) { + send(AdcCommand(AdcCommand::SEV_FATAL, AdcCommand::ERROR_TRANSFER_GENERIC, "Unsupported k")); + return; + } + + size_t n = ShareManager::getInstance()->getSharedFiles(); + + // Ideal size for m is n * k / ln(2), but we allow some slack + if(m > (5 * n * k / log(2))) { + send(AdcCommand(AdcCommand::SEV_FATAL, AdcCommand::ERROR_TRANSFER_GENERIC, "Unsupported m")); + return; + } + ShareManager::getInstance()->getBloom(v, k, m); AdcCommand cmd(AdcCommand::CMD_SND, AdcCommand::TYPE_HUB); cmd.addParam(c.getParam(0)); Modified: dcplusplus/trunk/dcpp/ShareManager.cpp =================================================================== --- dcplusplus/trunk/dcpp/ShareManager.cpp 2007-12-23 11:04:30 UTC (rev 949) +++ dcplusplus/trunk/dcpp/ShareManager.cpp 2007-12-23 20:29:57 UTC (rev 950) @@ -844,7 +844,6 @@ bloom.copy_to(v); } - void ShareManager::generateXmlList() { Lock l(cs); if(xmlDirty && (lastXmlUpdate + 15 * 60 * 1000 < GET_TICK() || lastXmlUpdate < lastFullUpdate)) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |