packets: limit chain locators.

This commit is contained in:
Christopher Jeffrey 2017-01-22 20:05:07 -08:00
parent 00f24dc11e
commit e32f521a43
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD

View File

@ -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'));