{\r
vector<CAddress> vAddr;\r
vRecv >> vAddr;\r
- if (vAddr.size() > 50000) // lower this to 1000 later\r
+ if (pfrom->nVersion < 200) // don't want addresses from 0.1.5\r
+ return true;\r
+ if (vAddr.size() > 1000)\r
return error("message addr size() = %d", vAddr.size());\r
\r
// Store the new addresses\r
if (pto->setAddrKnown.insert(addr).second)\r
{\r
vAddr.push_back(addr);\r
+ // receiver rejects addr messages larger than 1000\r
if (vAddr.size() >= 1000)\r
{\r
pto->PushMessage("addr", vAddr);\r
if (addrLocalHost.IsRoutable() && !fUseProxy)\r
{\r
// Advertise our address\r
- vector<CAddress> vAddrToSend;\r
- vAddrToSend.push_back(addrLocalHost);\r
- pnode->PushMessage("addr", vAddrToSend);\r
+ vector<CAddress> vAddr;\r
+ vAddr.push_back(addrLocalHost);\r
+ pnode->PushMessage("addr", vAddr);\r
}\r
\r
// Get as many addresses as we can\r
\r
bool IsRoutable() const\r
{\r
- return !(GetByte(3) == 10 ||\r
- (GetByte(3) == 192 && GetByte(2) == 168) ||\r
- GetByte(3) == 127 ||\r
- GetByte(3) == 0 ||\r
- ip == 0 ||\r
- ip == INADDR_NONE);\r
+ return IsValid() &&\r
+ !(GetByte(3) == 10 ||\r
+ (GetByte(3) == 192 && GetByte(2) == 168) ||\r
+ GetByte(3) == 127 ||\r
+ GetByte(3) == 0);\r
}\r
\r
bool IsValid() const\r
{\r
+ // Clean up 3-byte shifted addresses caused by garbage in size field\r
+ // of addr messages from versions before 0.2.9 checksum.\r
+ // Two consecutive addr messages look like this:\r
+ // header20 vectorlen3 addr26 addr26 addr26 header20 vectorlen3 addr26 addr26 addr26...\r
+ // so if the first length field is garbled, it reads the second batch\r
+ // of addr misaligned by 3 bytes.\r
+ if (memcmp(pchReserved, pchIPv4+3, sizeof(pchIPv4)-3) == 0)\r
+ return false;\r
+\r
return (ip != 0 && ip != INADDR_NONE && port != htons(USHRT_MAX));\r
}\r
\r
// Known checking here is only to save space from duplicates.\r
// SendMessages will filter it again for knowns that were added\r
// after addresses were pushed.\r
- if (!setAddrKnown.count(addr))\r
+ if (addr.IsValid() && !setAddrKnown.count(addr))\r
vAddrToSend.push_back(addr);\r
}\r
\r
class CDataStream;\r
class CAutoFile;\r
\r
-static const int VERSION = 210;\r
+static const int VERSION = 211;\r
static const char* pszSubVer = ".0";\r
\r
\r