Browse Source

correct excluded routers size for exploratory request

pull/1786/head
orignal 2 years ago
parent
commit
fc63ca6982
  1. 11
      libi2pd/NetDb.cpp

11
libi2pd/NetDb.cpp

@ -945,9 +945,9 @@ namespace data
} }
uint16_t numExcluded = bufbe16toh (excluded); uint16_t numExcluded = bufbe16toh (excluded);
excluded += 2; excluded += 2;
if (numExcluded > 512) if (numExcluded > 512 || (excluded - buf) + numExcluded*32 > (int)msg->GetPayloadLength ())
{ {
LogPrint (eLogWarning, "NetDb: Number of excluded peers", numExcluded, " exceeds 512"); LogPrint (eLogWarning, "NetDb: Number of excluded peers", numExcluded, " is too much");
return; return;
} }
@ -956,10 +956,11 @@ namespace data
{ {
LogPrint (eLogInfo, "NetDb: Exploratory close to ", key, " ", numExcluded, " excluded"); LogPrint (eLogInfo, "NetDb: Exploratory close to ", key, " ", numExcluded, " excluded");
std::set<IdentHash> excludedRouters; std::set<IdentHash> excludedRouters;
const uint8_t * excluded_ident = excluded;
for (int i = 0; i < numExcluded; i++) for (int i = 0; i < numExcluded; i++)
{ {
excludedRouters.insert (excluded); excludedRouters.insert (excluded_ident);
excluded += 32; excluded_ident += 32;
} }
std::vector<IdentHash> routers; std::vector<IdentHash> routers;
for (int i = 0; i < 3; i++) for (int i = 0; i < 3; i++)
@ -1017,7 +1018,7 @@ namespace data
if (closestFloodfills.empty ()) if (closestFloodfills.empty ())
LogPrint (eLogWarning, "NetDb: Requested ", key, " not found, ", numExcluded, " peers excluded"); LogPrint (eLogWarning, "NetDb: Requested ", key, " not found, ", numExcluded, " peers excluded");
replyMsg = CreateDatabaseSearchReply (ident, closestFloodfills); replyMsg = CreateDatabaseSearchReply (ident, closestFloodfills);
} }
} }
excluded += numExcluded * 32; excluded += numExcluded * 32;
if (replyMsg) if (replyMsg)

Loading…
Cancel
Save