linuxdcpp-team team mailing list archive
-
linuxdcpp-team team
-
Mailing list archive
-
Message #06126
[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 3074: Fix BLOM when h > 32
------------------------------------------------------------
revno: 3074
committer: poy <poy@xxxxxxxxxx>
branch nick: trunk
timestamp: Thu 2012-10-11 18:37:31 +0200
message:
Fix BLOM when h > 32
modified:
changelog.txt
dcpp/AdcHub.cpp
dcpp/HashBloom.cpp
test/testbloom.cpp
win32/AboutDlg.cpp
--
lp:dcplusplus
https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk
Your team Dcplusplus-team is subscribed to branch lp:dcplusplus.
To unsubscribe from this branch go to https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk/+edit-subscription
=== modified file 'changelog.txt'
--- changelog.txt 2012-10-11 16:17:05 +0000
+++ changelog.txt 2012-10-11 16:37:31 +0000
@@ -3,6 +3,7 @@
* Less CPU consumption with large hubs/queues/lists (poy)
* Fix incorrect user lists when DC++ is under heavy load (poy)
* Plug resource leaks (poy)
+* [L#411484] [ADC] Fix BLOM when h > 32 (thanks yorhel)
-- 0.801 2012-09-29 --
* [L#1029629] Prevent crashes on heavy use by updating Boost.Atomic
=== modified file 'dcpp/AdcHub.cpp'
--- dcpp/AdcHub.cpp 2012-07-01 18:41:13 +0000
+++ dcpp/AdcHub.cpp 2012-10-11 16:37:31 +0000
@@ -553,7 +553,8 @@
size_t n = ShareManager::getInstance()->getSharedFiles();
// Ideal size for m is n * k / ln(2), but we allow some slack
- if(m > (5 * Util::roundUp((int64_t)(n * k / log(2.)), (int64_t)64)) || m > static_cast<size_t>(1 << h)) {
+ // When h >= 32, m can't go above 2^h anyway since it's stored in a size_t.
+ if(m > (5 * Util::roundUp((int64_t)(n * k / log(2.)), (int64_t)64)) || (h < 32 && m > static_cast<size_t>(1U << h))) {
send(AdcCommand(AdcCommand::SEV_FATAL, AdcCommand::ERROR_TRANSFER_GENERIC,
"Unsupported m", AdcCommand::TYPE_HUB));
return;
=== modified file 'dcpp/HashBloom.cpp'
--- dcpp/HashBloom.cpp 2012-01-13 20:55:20 +0000
+++ dcpp/HashBloom.cpp 2012-10-11 16:37:31 +0000
@@ -38,7 +38,7 @@
uint64_t HashBloom::get_m(size_t n, size_t k) {
uint64_t m = (static_cast<uint64_t>(ceil(static_cast<double>(n) * k / log(2.))));
// 64-bit boundary as per spec
- return ((m + 63 )/ 64) * 64;
+ return ((m + 63ULL) / 64ULL) * 64ULL;
}
void HashBloom::add(const TTHValue& tth) {
@@ -83,7 +83,7 @@
size_t pos = bit % 8;
if(tth.data[byte] & (1 << pos)) {
- x |= (1 << i);
+ x |= (1LL << i);
}
}
return x % bloom.size();
=== modified file 'test/testbloom.cpp'
--- test/testbloom.cpp 2012-09-15 14:25:58 +0000
+++ test/testbloom.cpp 2012-10-11 16:37:31 +0000
@@ -122,6 +122,6 @@
bloom.reset(2, 1024, 64);
bloom.add(TTHValue("UDRJ6EGCH3CGWIIU2V6CH7VLFN4N2PCZKSPTBQA"));
bloom.copy_to(v);
- ASSERT_EQ("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
+ ASSERT_EQ("AAAAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
HashValue<Hasher>(&v[0]).toBase32());
}
=== modified file 'win32/AboutDlg.cpp'
--- win32/AboutDlg.cpp 2012-07-03 19:15:39 +0000
+++ win32/AboutDlg.cpp 2012-10-11 16:37:31 +0000
@@ -59,7 +59,7 @@
"steven sheehy, tobias nygren, poy, dorian, stephan hohe, mafa_45, mikael eman, james ross, "
"stanislav maslovski, david grundberg, pavel andreev, yakov suraev, kulmegil, smir, emtee, individ, "
"pseudonym, crise, ben, ximin luo, radox, razzloss, andrew browne, darkklor, vasily.n, netcelli, "
-"gennady proskurin, iceman50, flow84, alexander sashnov. Keep it coming!";
+"gennady proskurin, iceman50, flow84, alexander sashnov, yorhel. Keep it coming!";
AboutDlg::AboutDlg(dwt::Widget* parent) :
dwt::ModalDialog(parent),