1diff -uNr a/bitcoin/src/main.cpp b/bitcoin/src/main.cpp
2--- a/bitcoin/src/main.cpp 1f0735d2cee2f9ca2a177aead4ecc7a1371d59c4375aedb172ee99c28b02fa28e664decec9580a510bfca4738d85e377fb74396fe4979b75adbe1a3ec92b01c9
3+++ b/bitcoin/src/main.cpp 8d726cc72e81befff25d5872e757975c5ee538a6f51a930493fff9b435e4458c736401907fa5d589368cb4a4862614e6fe16ea30cfd568184916733289477a1b
4@@ -1877,6 +1877,9 @@
5 return error("message getdata size() = %d", vInv.size());
6 }
7
8+ // Counter of bytes sent in response to this 'getdata' command
9+ unsigned int sentBytes = 0;
10+
11 BOOST_FOREACH(const CInv& inv, vInv)
12 {
13 if (fShutdown)
14@@ -1891,6 +1894,17 @@
15 {
16 CBlock block;
17 block.ReadFromDisk((*mi).second);
18+
19+ // Add block's size to sentBytes, and determine if reached limit
20+ sentBytes += block.GetSerializeSize(SER_NETWORK);
21+ if (sentBytes >= SendBufferSize())
22+ {
23+ printf("getdata (block) may not transmit %u bytes\n", sentBytes);
24+ pfrom->Misbehaving(20);
25+ break;
26+ }
27+
28+ // Limit not reached, so permitted to send block
29 pfrom->PushMessage("block", block);
30
31 // Trigger them to send a getblocks request for the next batch of inventory