diff --git a/lib/net/packets.js b/lib/net/packets.js index c760a18e..bf746d07 100644 --- a/lib/net/packets.js +++ b/lib/net/packets.js @@ -977,6 +977,8 @@ GetBlocksPacket.prototype.getSize = function getSize() { GetBlocksPacket.prototype.toWriter = function toWriter(bw) { var i; + assert(this.locator.length <= 50000, 'Too many block hashes.'); + bw.writeU32(this.version); bw.writeVarint(this.locator.length); @@ -1011,6 +1013,8 @@ GetBlocksPacket.prototype.fromReader = function fromReader(br) { count = br.readVarint(); + assert(count <= 50000, 'Too many block hashes.'); + for (i = 0; i < count; i++) this.locator.push(br.readHash('hex'));