What changed
Bitcoin v0.2.10 → v0.2.11
Release commit message: more addr message error checking -- version 0.2.11
Previous diff: v0.2.9 → v0.2.10. Next: v0.2.11 → v0.2.12.
- main.cpp modified · +4 −1
- makefile.unix modified · +1 −1
- net.cpp modified · +3 −3
- net.h modified · +15 −7
- serialize.h modified · +1 −1
main.cpp (modified)
1--- v0.2.10/main.cpp2+++ v0.2.11/main.cpp3@@ -1926,7 +1926,9 @@4 {5 vector<CAddress> vAddr;6 vRecv >> vAddr;7- if (vAddr.size() > 50000) // lower this to 1000 later8+ if (pfrom->nVersion < 200) // don't want addresses from 0.1.59+ return true;10+ if (vAddr.size() > 1000)11 return error("message addr size() = %d", vAddr.size());12 13 // Store the new addresses14@@ -2311,6 +2313,7 @@15 if (pto->setAddrKnown.insert(addr).second)16 {17 vAddr.push_back(addr);18+ // receiver rejects addr messages larger than 100019 if (vAddr.size() >= 1000)20 {21 pto->PushMessage("addr", vAddr);
makefile.unix (modified)
1--- v0.2.10/makefile.unix2+++ v0.2.11/makefile.unix3@@ -29,7 +29,7 @@4 5 WXDEFS=-D__WXGTK__ -DNOPCH6 DEBUGFLAGS=-g -D__WXDEBUG__7-CFLAGS=-O2 -Wno-invalid-offsetof -Wformat $(DEBUGFLAGS) $(WXDEFS) $(INCLUDEPATHS)8+CFLAGS=-O0 -Wno-invalid-offsetof -Wformat $(DEBUGFLAGS) $(WXDEFS) $(INCLUDEPATHS)9 HEADERS=headers.h strlcpy.h serialize.h uint256.h util.h key.h bignum.h base58.h \10 script.h db.h net.h irc.h main.h rpc.h uibase.h ui.h init.h sha.h11
net.cpp (modified)
1--- v0.2.10/net.cpp2+++ v0.2.11/net.cpp3@@ -968,9 +968,9 @@4 if (addrLocalHost.IsRoutable() && !fUseProxy)5 {6 // Advertise our address7- vector<CAddress> vAddrToSend;8- vAddrToSend.push_back(addrLocalHost);9- pnode->PushMessage("addr", vAddrToSend);10+ vector<CAddress> vAddr;11+ vAddr.push_back(addrLocalHost);12+ pnode->PushMessage("addr", vAddr);13 }14 15 // Get as many addresses as we can
net.h (modified)
1--- v0.2.10/net.h2+++ v0.2.11/net.h3@@ -289,16 +289,24 @@4 5 bool IsRoutable() const6 {7- return !(GetByte(3) == 10 ||8- (GetByte(3) == 192 && GetByte(2) == 168) ||9- GetByte(3) == 127 ||10- GetByte(3) == 0 ||11- ip == 0 ||12- ip == INADDR_NONE);13+ return IsValid() &&14+ !(GetByte(3) == 10 ||15+ (GetByte(3) == 192 && GetByte(2) == 168) ||16+ GetByte(3) == 127 ||17+ GetByte(3) == 0);18 }19 20 bool IsValid() const21 {22+ // Clean up 3-byte shifted addresses caused by garbage in size field23+ // of addr messages from versions before 0.2.9 checksum.24+ // Two consecutive addr messages look like this:25+ // header20 vectorlen3 addr26 addr26 addr26 header20 vectorlen3 addr26 addr26 addr26...26+ // so if the first length field is garbled, it reads the second batch27+ // of addr misaligned by 3 bytes.28+ if (memcmp(pchReserved, pchIPv4+3, sizeof(pchIPv4)-3) == 0)29+ return false;30+31 return (ip != 0 && ip != INADDR_NONE && port != htons(USHRT_MAX));32 }33 34@@ -619,7 +627,7 @@35 // Known checking here is only to save space from duplicates.36 // SendMessages will filter it again for knowns that were added37 // after addresses were pushed.38- if (!setAddrKnown.count(addr))39+ if (addr.IsValid() && !setAddrKnown.count(addr))40 vAddrToSend.push_back(addr);41 }42
serialize.h (modified)
1--- v0.2.10/serialize.h2+++ v0.2.11/serialize.h3@@ -19,7 +19,7 @@4 class CDataStream;5 class CAutoFile;6 7-static const int VERSION = 210;8+static const int VERSION = 211;9 static const char* pszSubVer = ".0";10 11
