diff -uNr a/bitcoin/manifest b/bitcoin/manifest --- a/bitcoin/manifest 1b686bcb52a6a5df9ee7db45315e32fd9b90ebff8783cde2aec664538b6722a972be2c060c4dc97eb5138f454413a2df670ed361b120bfa43acba686aeb9a54f +++ b/bitcoin/manifest a0c64e555d333fb196a4b6c825bb7f7f80bc755af157c56a8836762080ad259d29f26cb5276145dc0cf0b8fb99806e63da21bd16055bf209e2937b388153f8aa @@ -32,3 +32,4 @@ 616451 mod6_phexdigit_fix mod6 Adds missing comma to separate values in the phexdigit array in util.cpp. 617254 mod6_excise_hash_truncation mod6 Regrind of ben_vulpes original; Removes truncation of hashes printed to TRB log file 617255 mod6_whogaveblox mod6 Regrind of asciilifeform original; Record the origin of every incoming candidate block (whether accepted or rejected) +621797 mod6_getdata_blocks_wrangler mod6 Check size limit while sending responses to getdata when blocks requested diff -uNr a/bitcoin/src/main.cpp b/bitcoin/src/main.cpp --- a/bitcoin/src/main.cpp 1f0735d2cee2f9ca2a177aead4ecc7a1371d59c4375aedb172ee99c28b02fa28e664decec9580a510bfca4738d85e377fb74396fe4979b75adbe1a3ec92b01c9 +++ b/bitcoin/src/main.cpp d2cfb49e32a09678daf8e9e1d57872f7f37856664e443026046b3d66cc272062e13549c4a95e8a8335089bc165ab5e9d15f1808bcfd713ec97d41d20242026f7 @@ -1877,6 +1877,9 @@ return error("message getdata size() = %d", vInv.size()); } + // Counter of bytes sent in response to this 'getdata' command + unsigned int sentBytes = 0; + BOOST_FOREACH(const CInv& inv, vInv) { if (fShutdown) @@ -1891,6 +1894,17 @@ { CBlock block; block.ReadFromDisk((*mi).second); + + // Add block's size to sentBytes, and determine if reached limit + sentBytes += block.GetSerializeSize(SER_NETWORK); + if (sentBytes >= SendBufferSize()) + { + printf("getdata (block) may not transmit %u bytes\n", sentBytes); + pfrom->Misbehaving(20); + break; + } + + // Limit not reached, so permitted to send block pfrom->PushMessage("block", block); // Trigger them to send a getblocks request for the next batch of inventory